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

404
site/runshops/add.php Normal file
View File

@ -0,0 +1,404 @@
<?PHP
include("config.php");
if(!is_logged_in($user)){
header('Location: '.$site_url);
exit();
}
$username = base64_decode($_SESSION['user']);
$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];
// set the page title
$pagetitle = "Add a Shop";
// set meta tags
$meta_keywords = "add shop";
$meta_description = "Do you want to include your retail store in our online multisport retaler 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[addshop] == 1){
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( $_GET[confirmed] == "yes" ) { ?>
<h1 >Thank You</h1>
<p class="cont">Thank you. Your shop should be added within 24 hours. You will now be redirected back to the homepage page.</p>
<meta HTTP-EQUIV="Refresh" CONTENT="4; URL=index.php" />
<? } else if ( $confirm == 1 ) { ?>
<h1><strong>Add a Shop: Step 2 of 2</h1>
<? } else if ( ($confirm !=1) && ($_POST[confirm1] != 1)) { ?>
<h1>Add a Shop: Step 1 of 2</h1>
<? } else if ( ($_POST[addshop] == 1) && (!$errmsg) && ($_POST[confirm1] == 1)) { ?>
<h1>Thank you</h1>
<? } ?>
<hr class="line" />
<? include("include_region_list.php"); ?>
<? if (($confirm != 1) && ($_POST[confirm1] != 1) && $_GET[confirmed] != "yes") { ?>
<p class="cont">If you would like to add your triathlon/running shop to our website, simply fill out the form below. Be sure to fill out every field. After filling out each field, click submit. <font color="red">You will then be prompted to confirm your information before the information is sent to us.</font></p>
<? } ?>
<? if( $_GET[confirmed] != "yes" && (($_POST[addshop] != 1) || ($errmsg) || (($confirm != 1) && ($_POST[confirm1] != 1))) ) { ?>
<form enctype="multipart/form-data" action="add.php" method="post">
<p class="error"><? echo $errmsg; ?></p>
<div class="dtable form">
<div class="drow">
<div class="dcell name">Store Name</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input type="text" name="name" value="<? echo stripslashes($_POST[name]); ?>" class="txt lngtext" />
</div>
</div>
<div class="drow">
<div class="dcell name">Address</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input type="text" name="address" value="<? echo stripslashes(htmlspecialchars($_POST[address])); ?>" class="txt lngtext" />
</div>
</div>
<div class="drow">
<div class="dcell name">Address 2</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input type="text" name="address_two" value="<? echo stripslashes(htmlspecialchars($_POST[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 type="text" name="city" value="<? echo stripslashes(htmlspecialchars($_POST[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</option>
<?
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 type="text" name="zip" value="<? echo stripslashes(htmlspecialchars($_POST[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 type="text" name="phone" value="<? echo stripslashes(htmlspecialchars($_POST[phone])); ?>" class="txt shotext" />
</div>
</div>
<div class="drow">
<div class="dcell name">Fax</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input type="text" name="fax" value="<? echo stripslashes(htmlspecialchars($_POST[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 type="text" name="email" value="<? echo stripslashes(htmlspecialchars($_POST[email])); ?>" class="txt lngtext" />
</div>
</div>
<div class="drow">
<div class="dcell name">Website</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input type="text" name="website" value="<? echo stripslashes(htmlspecialchars($_POST[website])); ?>" class="txt lngtext" placeholder="http://" />
</div>
</div>
<div class="drow">
<div class="dcell name">Online Shopping Cart</div>
<div class="dcell divider"></div>
<div class="dcell value">
<select name="cart">
<option value="0" <? if ($_POST[cart] == 0) { echo "selected='selected'"; } ?>>No</option>
<option value="1" <? if ($_POST[cart] == 1) { echo "selected='selected'"; } ?>>Yes</option>
</select> (Must be a fully functional ecommerce system)
</div>
</div>
<div class="drow">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
for ($i = 0; $i < 10; $i++) echo("*");
echo (" TECHNOLOGY, COMMUNITY &amp; EDUCATION ");
for ($i = 0; $i < 10; $i++) echo("*");
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Key Tri-Specific Contact(s)</div>
<div class="dcell divider"></div>
<div class="dcell value">
<select name="contact">
<option value="0" <? if ($_POST[contact] == 0) { echo "selected='selected'"; } ?>>None</option>
<option value="1" <? if ($_POST[contact] == 1) { echo "selected='selected'"; } ?>>Yes, Their Names</option>
</select>
<input type="text" name="contact_names" value="<? echo stripslashes($_POST[contact_names]); ?>" class="txt shotext" />
</div>
</div>
<div class="drow">
<div class="dcell name">Diagnostic Equipment</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
$explosion = array("");
if (!is_array($_POST[diagnostics])){ $explosion = explode(",", $_POST[diagnostics]); } else { $explosion = $_POST[diagnostics]; }
$results = mysql_query("SELECT * FROM ".$prefix."RunshopsDiagnostics ORDER BY diagnostic_name ASC");
echo("<input type=\"hidden\" name=\"diagnostics[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
echo("<input type=\"checkbox\" name=\"diagnostics[]\" value=\"$row[diagnostic_id]\" ");
if (in_array($row[diagnostic_id], $explosion)) { echo "checked "; }
echo(">$row[diagnostic_name]");
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
for ($i = 0; $i < 25; $i++) echo("*");
echo (" BRANDS ");
for ($i = 0; $i < 25; $i++) echo("*");
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Running Shoes</div>
<div class="dcell divider"></div>
<div class="dcell value">
<p class="note">IMPORTANT: Running shoe brands of which you'll have almost
full size runs in stock of most of the important run models at almost all
times.</p>
<?
$explosion = array("");
if (!is_array($_POST[shoes])){ $explosion = explode(",", $_POST[shoes]); } else { $explosion = $_POST[shoes]; }
$results = mysql_query("SELECT * FROM ".$prefix."RunshopsShoes ORDER BY shoe_name ASC");
echo("<input type=\"hidden\" name=\"shoes[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
echo("<span class=\"col\"><input type=\"checkbox\" name=\"shoes[]\" value=\"$row[shoe_id]\" ");
if (in_array($row[shoe_id], $explosion)){ echo "checked "; }
echo(" />$row[shoe_name]</span>");
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Socks</div>
<div class="dcell divider"></div>
<div class="dcell value">
<p class="note">IMPORTANT: Sock brands you'll keep in stock almost all the time.</p>
<?
$explosion = array("");
if (!is_array($_POST[socks])){ $explosion = explode(",", $_POST[socks]); } else { $explosion = $_POST[socks]; }
$results = mysql_query("SELECT * FROM ".$prefix."RunshopsSocks ORDER BY sock_name ASC");
echo("<input type=\"hidden\" name=\"socks[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
echo("<span class=\"col\"><input type=\"checkbox\" name=\"socks[]\" value=\"$row[sock_id]\" ");
if (in_array($row[sock_id], $explosion)){ echo "checked "; }
echo(" />$row[sock_name]</span>");
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Run Focused Apparel</div>
<div class="dcell divider"></div>
<div class="dcell value">
<p class="note">IMPORTANT: Run focus apparel brands you'll keep in stock, full size runs, almost all the time, season-appropriate.</p>
<?
$explosion = array("");
if (!is_array($_POST[apparel_run])){ $explosion = explode(",", $_POST[apparel_run]); } else { $explosion = $_POST[apparel_run]; }
$results = mysql_query("SELECT * FROM ".$prefix."RunshopsApparelRun ORDER BY apparel_run_name ASC");
echo("<input type=\"hidden\" name=\"apparel_run[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
echo("<span class=\"col\"><input type=\"checkbox\" name=\"apparel_run[]\" value=\"$row[apparel_run_id]\" ");
if (in_array($row[apparel_run_id], $explosion)){ echo "checked "; }
echo("/> $row[apparel_run_name]</span>");
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Tri Focused Apparel</div>
<div class="dcell divider"></div>
<div class="dcell value">
<p class="note">IMPORTANT: Run/tri apparel brands you'll keep in stock, full size runs, almost
all the time, season-appropriate.</p>
<?
$explosion = array("");
if (!is_array($_POST[apparel_tri])){ $explosion = explode(",", $_POST[apparel_tri]); } else { $explosion = $_POST[apparel_tri]; }
$results = mysql_query("SELECT * FROM ".$prefix."RunshopsApparelTri ORDER BY apparel_tri_name ASC");
echo("<input type=\"hidden\" name=\"apparel_tri[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
echo("<span class=\"col\"><input type=\"checkbox\" name=\"apparel_tri[]\" value=\"$row[apparel_tri_id]\" ");
if (in_array($row[apparel_tri_id], $explosion)){ echo "checked "; }
echo("/> $row[apparel_tri_name]</span>");
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Swim Gear</div>
<div class="dcell divider"></div>
<div class="dcell value">
<p class="note">IMPORTANT: Swimwear/Goggles: Brands you carry wide and deep, with models that are
swim-specific.</p>
<?
$explosion = array("");
if (!is_array($_POST[swimgear])){ $explosion = explode(",", $_POST[swimgear]); } else { $explosion = $_POST[swimgear]; }
$results = mysql_query("SELECT * FROM ".$prefix."ResourceSwimgear ORDER BY swimgear_name ASC");
echo("<input type=\"hidden\" name=\"swimgear[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
echo("<span class=\"col\"><input type=\"checkbox\" name=\"swimgear[]\" value=\"$row[swimgear_id]\" ");
if (in_array($row[swimgear_id], $explosion)){ echo "checked "; }
echo("/>$row[swimgear_name]</span>\n");
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Wetsuits</div>
<div class="dcell divider"></div>
<div class="dcell value">
<p class="note">IMPORTANT: Wetsuit brands of which you'll have 12 or more continually in stock during the season.</p>
<?
$explosion = array("");
if (!is_array($_POST[wetsuits])){ $explosion = explode(",", $_POST[wetsuits]); } else { $explosion = $_POST[wetsuits]; }
$results = mysql_query("SELECT * FROM ".$prefix."ResourceWetsuit ORDER BY wetsuit_name ASC");
echo("<input type=\"hidden\" name=\"wetsuits[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
echo("<span class=\"col\"><input type=\"checkbox\" name=\"wetsuits[]\" value=\"$row[wetsuit_id]\" ");
if (in_array($row[wetsuit_id], $explosion)){ echo "checked "; }
echo("/> $row[wetsuit_name]</span>");
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<? for ($i = 0; $i < 60; $i++) echo("*"); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Store Hours</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input type="text" name="hours" value="<? echo stripslashes(htmlspecialchars($_POST[hours])); ?>" class="txt lngtext" /></td>
</div>
</div>
<div class="drow">
<div class="dcell name">Runs &amp; Classes</div>
<div class="dcell divider"></div>
<div class="dcell value">
<textarea name="classes" class="txt lngtext" placeholder="Place here times and days of regular runs emanating from the shop, with distances and pace (easy-moderate-fast); also whether you host running classes, when, and any cost associated.">
<? if($_POST[classes]){ echo strip_tags(stripslashes($_POST[classes])); } ?>
</textarea>
</div>
</div>
<div class="drow">
<div class="dcell name">Shop Info</div>
<div class="dcell divider"></div>
<div class="dcell value">
<textarea name="info" class="txt lngtext" placeholder="Please write some information about your shop.">
<? if($_POST[info]){ echo strip_tags(stripslashes($_POST[info])); } ?>
</textarea>
</div>
</div>
<div class="drow">
<div class="dcell name">Directions</div>
<div class="dcell divider"></div>
<div class="dcell value">
<textarea name="directions" class="txt lngtext" placeholder="Please describe how to get to your shop from your surrounding area.">
<? if($_POST[directions]) { echo strip_tags(stripslashes($_POST[directions])); } ?>
</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="addshop" value="1" />
</div>
</div>
</div>
</form>
<? } else {
if (($_POST[addshop] == 1) && (!$errmsg) && ($_POST[confirm1] == 1)) {
echo "<p class=\"cont\">Thank you. Your shop should be added within 24 hours. You will now be redirected back to the home page.</p>";
echo "<META HTTP-EQUIV=Refresh CONTENT=\"4; URL=index.php\">";
}
if ($confirm == 1) {
$confirm = 0;
include("include_add_confirm.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>

124
site/runshops/add_X.php Normal file
View File

@ -0,0 +1,124 @@
<?PHP
if (!$_POST){ header('Location: '.$site_url); }
/*
FIELD NAMES:
runshop_id
runshop_name
runshop_name_tag
runshop_address
runshop_address_two
runshop_city
runshop_state
runshop_state_tag
runshop_zip
runshop_phone
runshop_fax
runshop_email
runshop_website
runshop_cart
runshop_contact
runshop_contact_names
runshop_diagnostics
runshop_shoes
runshop_socks
runshop_apparel_run
runshop_apparel_tri
runshop_swimgear
runshop_wetsuits
runshop_hours
runshop_classes
runshop_info
runshop_directions
runshop_submitted_by
runshop_valid
runshop_shopper_tags
*/
/* Need to ltrim and rtrim commas before insertion */
//Insert into database
$errmsg = 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[hours]) $errmsg = $errmsg.'Shop hours, ';
if ($_POST[contact] == 1 && !$_POST[contact_names]) $errmsg = $errmsg.'Contact names, ';
if (strlen($_POST[classes]) < 4) $errmsg = $errmsg.'Runs &amp; classes, ';
if (strlen($_POST[info]) < 4) $errmsg = $errmsg.'Shop info, ';
if (strlen($_POST[directions]) < 4) $errmsg = $errmsg.'Directions, ';
if (isset($errmsg)) {
$errmsg = 'The following fields cannot be left blank: '.$errmsg;
$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]) && $_POST[website] != "") {
// Contains invalid characters.
$errmsg = $errmsg."Invalid Web Address<br />";
}
if( preg_match('/[^a-zA-Z0-9\. ]/', $_POST[name]) ) {
// Contains invalid characters.
$errmsg = "Please use only letters and numbers in the name";
}
if(!$errmsg){
$name = mysql_real_escape_string(trim($_POST[name]));
$name_tag = mysql_real_escape_string(strtolower(str_replace(" ","", $name)));
if(strlen($nametag) > 12){ //Shorten it
$name_tag = substr($nametag, 0, 12);
}
$address = mysql_real_escape_string(trim($_POST[address]));
$address_two = mysql_real_escape_string(trim($_POST[address_two]));
$city = mysql_real_escape_string(trim($_POST[city]));
$state = mysql_real_escape_string($_POST[state]);
$state_tag = mysql_real_escape_string(strtolower(str_replace(" ","", $state)));
$zip = mysql_real_escape_string(trim($_POST[zip]));
$phone = mysql_real_escape_string(trim($_POST[phone]));
$fax = mysql_real_escape_string(trim($_POST[fax]));
$email = mysql_real_escape_string(trim($_POST[email]));
$website = mysql_real_escape_string(trim($_POST[website]));
$cart = mysql_real_escape_string(trim($_POST[cart]));
$contact = mysql_real_escape_string($_POST[contact]);
if ( $contact == 0 ){ $contact_names = NULL; }else{ $contact_names = mysql_real_escape_string(trim($_POST[contact_names])); }
/* Need to ltrim and rtrim commas before insertion --> or ltrim/rtrim before implosion*/
$diagnostics = mysql_real_escape_string($_POST[diagnostics]);
$shoes = mysql_real_escape_string($_POST[shoes]);
$socks = mysql_real_escape_string($_POST[socks]);
$apparelrun = mysql_real_escape_string($_POST[apparel_run]);
$appareltri = mysql_real_escape_string($_POST[apparel_tri]);
$swimgear = mysql_real_escape_string($_POST[swimgear]);
$wetsuits = mysql_real_escape_string($_POST[wetsuits]);
$hours = mysql_real_escape_string(trim($_POST[hours]));
$classes = mysql_real_escape_string(nl2br(substr(trim($_POST[classes]), 0, 4096)));
$info = mysql_real_escape_string(nl2br(substr(trim($_POST[info]), 0, 4096)));
$directions = mysql_real_escape_string(nl2br(substr(trim($_POST[directions]), 0, 4096)));
$submitted_by = mysql_real_escape_string($_POST[submitted_by]);
if($_POST[confirm1] == 1){
$sql = "INSERT INTO ".$prefix."Runshops (runshop_name, runshop_name_tag, runshop_address, runshop_address_two, runshop_city, runshop_state, runshop_state_tag, runshop_zip, runshop_phone, runshop_fax, runshop_email, runshop_website, runshop_cart, runshop_contact, runshop_contact_names, runshop_diagnostics, runshop_shoes, runshop_socks, runshop_apparel_run, runshop_apparel_tri, runshop_swimgear, runshop_wetsuits, runshop_hours, runshop_classes, runshop_info, runshop_directions, runshop_submitted_by, runshop_valid) VALUES ('$name', '$name_tag', '$address', '$address_two', '$city', '$state', '$state_tag', '$zip', '$phone', '$fax', '$email', '$website', '$cart', $contact, '$contact_names', ',$diagnostics,', ',$shoes,', ',$socks,', ',$apparelrun,', ',$appareltri,', ',$swimgear,', ',$wetsuits,', '$hours', '$classes', '$info', '$directions', $submitted_by, 0)";
//echo("shop entered!");
//echo($sql);
//exit();
mysql_query($sql) OR die(mysql_error());
//exit();
}else{
//echo("shop NOT entered.");
$confirm = 1;
}
}
?>

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,31 @@
<?PHP
?>
<form action="comments_add_X.php" method="post">
<input type="hidden" name="runshop_id" value="<? echo $row[runshop_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
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();
$runshop_id = $_POST[runshop_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."RunshopsComment (runshop_id_fk, comment_time, user_id_fk, comment_subject, comment_message, comment_ip, comment_valid) VALUES ($runshop_id, '$tsNow', '$editor_id', '$subject', '$message', '$ip', 0)";
//echo $sql;
mysql_query($sql) or die(mysql_error());
header('Location: '.$site_url.'/individual.php?runshop_id='.$runshop_id.'&review_add=ok');
exit();
} else {
header('Location: '.$site_url.'/index.php?comment_error=no_post');
die('comment_error=no_post');
}
?>

View File

@ -0,0 +1,8 @@
<?PHP
if (eregi("comments_show.php", $_SERVER['SCRIPT_NAME'])) {
Header("Location: index.php"); die();
}
$fb_xid = intval(mysql_escape_string($_GET[uid]));
?>
<a name="comment"></a>
<fb:comments href="<? echo(curPageURL()); ?>" num_posts="5" width="622"></fb:comments>

View File

@ -0,0 +1,84 @@
<?PHP
include("config.php");
if(!is_admin()){
header('Location: '.$site_url);
exit();
}
// Query to fetch non-validated shops:
$results = mysql_query("SELECT * FROM ".$prefix."RunshopsComment 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"));
$arrRaces = mysql_fetch_array(mysql_query("SELECT runshop_name FROM ".$prefix."Runshops WHERE runshop_id = ".$arrComments[runshop_id_fk]." LIMIT 1"));
$commenter_user_username = $arrCommenters[user_username];
$runshop_name = $arrRaces[runshop_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?runshop_id=".$arrComments[runshop_id_fk]."\">".$runshop_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,35 @@
<?PHP
include("config.php");
if ((!isset($_POST['delete']) && !isset($_POST['validate'])) || !is_admin()) {
header('Location: '.$site_url);
die("comment_validation_error");
}
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."RunshopsComment 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."RunshopsComment
SET comment_valid = 1
WHERE comment_id IN $comment_idlist;";
mysql_query($sql) or die(mysql_error());
}
header('Location: '.$site_url.'/comments_validate.php');
?>

85
site/runshops/config.php Normal file
View File

@ -0,0 +1,85 @@
<?
###########################################
#-----------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 \\
\\
===========================================\
------------------------------------------*/
//skip the config file if somebody call it from the browser.
session_start();
if (eregi("config.php", $_SERVER['SCRIPT_NAME'])) {
Header("Location: ".$site_url."/index.php"); die();
}
$main_table = "Runshops";
$field_lead = "runshop_";
$site_url = "/runshops";
include("../local/settings.php");
//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'); */
}
$sql = "SELECT * FROM ".$prefix."ResourceStates ORDER BY stateid";
$result = mysql_query($sql) OR die(mysql_error());
$state_list = array();
$state_tag_list = array();
while ($row = mysql_fetch_array($result)) {
$state_list[$row['stateid']] = $row['statelong'];
$state_tag_list[] = $row['statetag'];
}
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;
}
?>

View File

@ -0,0 +1,29 @@
<?PHP
include("config.php");
if (!$_POST || !is_admin()){ header('Location: '.$site_url); }
$sql = "DELETE FROM ".$prefix."Runshops WHERE runshop_id = '$_POST[runshop_id]'";
mysql_query($sql) or die(mysql_error());
$sql = "DELETE FROM ".$prefix."RunshopsEdits WHERE runshop_id_fk = '$_POST[runshop_id]'";
mysql_query($sql) or die(mysql_error());
$sql = "DELETE FROM ".$prefix."RunshopsEditors WHERE runshop_id_fk = '$_POST[runshop_id]'";
mysql_query($sql) or die(mysql_error());
$sql = "DELETE FROM ".$prefix."RunshopsComment WHERE runshop_id_fk = '$_POST[runshop_id]'";
mysql_query($sql) or die(mysql_error());
$sql = "DELETE FROM ".$prefix."RunshopsRating WHERE runshop_id_fk = '$_POST[runshop_id]'";
mysql_query($sql) or die(mysql_error());
header('Location: '.$site_url);
?>

View File

@ -0,0 +1,324 @@
<p>
Please confirm your shop information. If everything is correct, click the submit button. Otherwise, you may click the edit button to change your shop information before submitting.
</p>
<?$nametagmod = trim(strtolower(str_replace(" ","",$_POST[name])));?>
<div class="dtable form">
<div class="drow">
<div class="dcell name">Store Name</div>
<div class="dcell divider"></div>
<div class="dcell value"><? echo stripslashes($_POST[name]); ?></div>
</div>
<div class="drow">
<div class="dcell name">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">Address 2</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</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">Cart</div>
<div class="dcell divider"></div>
<div class="dcell value"><? if ($_POST[cart] == 0) { echo ("No"); } else { echo ("Yes"); } ?></div>
</div>
<div class="drow">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
for ($i = 0; $i < 10; $i++) echo("*");
echo (" TECHNOLOGY, COMMUNITY &amp; EDUCATION ");
for ($i = 0; $i < 10; $i++) echo("*");
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Key Tri-Specific Contact(s)</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? if ($_POST[contact] == 0) { echo "None"; } else { echo "Yes, Their Names - "; echo stripslashes($_POST[contact_names]); } ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Diagnostic Equipment</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
if ($_POST[diagnostics]) {
$implosion = implode(",", $_POST[diagnostics]);
$sql = ("SELECT * FROM ".$prefix."RunshopsDiagnostics WHERE diagnostic_id IN ($implosion) ORDER BY diagnostic_name ASC");
$results = mysql_query($sql) or die(mysql_error());
$diagnostic_list = "";
while ($row = mysql_fetch_array($results)) {
$diagnostic_list = $diagnostic_list."$row[diagnostic_name], ";
}
$diagnostic_list = rtrim($diagnostic_list, ', ');
echo $diagnostic_list;
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
for ($i = 0; $i < 25; $i++) echo("*");
echo (" BRANDS ");
for ($i = 0; $i < 25; $i++) echo("*");
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Running Shoes</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
if ($_POST[shoes]) {
$implosion = implode(",", $_POST[shoes]);
$sql = ("SELECT * FROM ".$prefix."RunshopsShoes WHERE shoe_id IN ($implosion) ORDER BY shoe_name ASC");
$results = mysql_query($sql) or die(mysql_error());
$shoe_list = "";
while ($row = mysql_fetch_array($results)) {
$shoe_list = $shoe_list."$row[shoe_name], ";
}
$shoe_list = rtrim($shoe_list, ', ');
echo $shoe_list;
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Socks</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
if ($_POST[socks]) {
$implosion = implode(",", $_POST[socks]);
$sql = ("SELECT * FROM ".$prefix."RunshopsSocks WHERE sock_id IN ($implosion) ORDER BY sock_name ASC");
$results = mysql_query($sql) or die(mysql_error());
$sock_list = "";
while ($row = mysql_fetch_array($results)) {
$sock_list = $sock_list."$row[sock_name], ";
}
$sock_list = rtrim($sock_list, ', ');
echo $sock_list;
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Run Focused Apparel</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
if ($_POST[apparel_run]) {
$implosion = implode(",", $_POST[apparel_run]);
$sql = ("SELECT * FROM ".$prefix."RunshopsApparelRun WHERE apparel_run_id IN ($implosion) ORDER BY apparel_run_name ASC");
$results = mysql_query($sql) or die(mysql_error());
$apparel_run_list = "";
while ($row = mysql_fetch_array($results)) {
$apparel_run_list = $apparel_run_list."$row[apparel_run_name], ";
}
$apparel_run_list = rtrim($apparel_run_list, ', ');
echo $apparel_run_list;
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Tri-Focused Apparel</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
if ($_POST[apparel_tri]) {
$implosion = implode(",", $_POST[apparel_tri]);
$sql = ("SELECT * FROM ".$prefix."RunshopsApparelTri WHERE apparel_tri_id IN ($implosion) ORDER BY apparel_tri_name ASC");
$results = mysql_query($sql) or die(mysql_error());
$apparel_tri_list = "";
while ($row = mysql_fetch_array($results)) {
$apparel_tri_list = $apparel_tri_list."$row[apparel_tri_name], ";
}
$apparel_tri_list = rtrim($apparel_tri_list, ', ');
echo $apparel_tri_list;
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Swim Gear</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
if ($_POST[swimgear]) {
$implosion = implode(",", $_POST[swimgear]);
$sql = ("SELECT * FROM ".$prefix."ResourceSwimgear WHERE swimgear_id IN ($implosion) ORDER BY swimgear_name ASC");
$results = mysql_query($sql) or die(mysql_error());
$swimgear_list = "";
while ($row = mysql_fetch_array($results)) {
$swimgear_list = $swimgear_list."$row[swimgear_name], ";
}
$swimgear_list = rtrim($swimgear_list, ', ');
echo $swimgear_list;
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Wetsuits</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
if ($_POST[wetsuits]) {
$implosion = implode(",", $_POST[wetsuits]);
$sql = ("SELECT * FROM ".$prefix."ResourceWetsuit WHERE wetsuit_id IN ($implosion) ORDER BY wetsuit_name ASC");
$results = mysql_query($sql) or die(mysql_error());
$wetsuit_list = "";
while ($row = mysql_fetch_array($results)) {
$wetsuit_list = $wetsuit_list."$row[wetsuit_name], ";
}
$wetsuit_list = rtrim($wetsuit_list, ', ');
echo $wetsuit_list;
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<? for ($i = 0; $i < 60; $i++) echo("*"); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Store Hours</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[hours])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Runs &amp; Classes</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo strip_tags(stripslashes($_POST[classes])) ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Shop 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">Directions</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo strip_tags(stripslashes($_POST[directions])); ?>
</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="cart" value="<? echo $_POST[cart]; ?>">
<input type="hidden" name="contact" value="<? echo $_POST[contact]; ?>">
<input type="hidden" name="contact_names" value="<? echo stripslashes(htmlspecialchars($_POST[contact_names])); ?>">
<input type="hidden" name="diagnostics" value="<? echo(implode(',', $_POST[diagnostics])); ?>">
<input type="hidden" name="shoes" value="<? echo(implode(',', $_POST[shoes])); ?>">
<input type="hidden" name="socks" value="<? echo(implode(',', $_POST[socks])); ?>">
<input type="hidden" name="apparel_run" value="<? echo(implode(',', $_POST[apparel_run])); ?>">
<input type="hidden" name="apparel_tri" value="<? echo(implode(',', $_POST[apparel_tri])); ?>">
<input type="hidden" name="swimgear" value="<? echo(implode(',', $_POST[swimgear])); ?>">
<input type="hidden" name="wetsuits" value="<? echo(implode(',', $_POST[wetsuits])); ?>">
<input type="hidden" name="hours" value="<? echo stripslashes(htmlspecialchars($_POST[hours])); ?>">
<input type="hidden" name="classes" value="<? echo stripslashes(htmlspecialchars($_POST[classes])); ?>">
<input type="hidden" name="info" value="<? echo stripslashes(htmlspecialchars($_POST[info])); ?>">
<input type="hidden" name="directions" value="<? echo stripslashes(htmlspecialchars($_POST[directions])); ?>">
<input type="hidden" name="addshop" value="1">
<input type="hidden" name="confirm1" value="1">
<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="cart" value="<? echo $_POST[cart]; ?>">
<input type="hidden" name="contact" value="<? echo $_POST[contact]; ?>">
<input type="hidden" name="contact_names" value="<? echo stripslashes(htmlspecialchars($_POST[contact_names])); ?>">
<input type="hidden" name="diagnostics" value="<? echo(implode(',', $_POST[diagnostics])); ?>">
<input type="hidden" name="shoes" value="<? echo(implode(',', $_POST[shoes])); ?>">
<input type="hidden" name="socks" value="<? echo(implode(',', $_POST[socks])); ?>">
<input type="hidden" name="apparel_run" value="<? echo(implode(',', $_POST[apparel_run])); ?>">
<input type="hidden" name="apparel_tri" value="<? echo(implode(',', $_POST[apparel_tri])); ?>">
<input type="hidden" name="swimgear" value="<? echo(implode(',', $_POST[swimgear])); ?>">
<input type="hidden" name="wetsuits" value="<? echo(implode(',', $_POST[wetsuits])); ?>">
<input type="hidden" name="hours" value="<? echo stripslashes(htmlspecialchars($_POST[hours])); ?>">
<input type="hidden" name="classes" value="<? echo stripslashes(htmlspecialchars($_POST[classes])); ?>">
<input type="hidden" name="info" value="<? echo stripslashes(htmlspecialchars($_POST[info])); ?>">
<input type="hidden" name="directions" value="<? echo stripslashes(htmlspecialchars($_POST[directions])); ?>">
<input type="submit" name="submit" value="Edit Information" class="btn float-left">
</form>
</div>
</div>
</div>

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[runshop_name]) { ?>
<a href="<? echo $site_url ?>">Running Stores</a>
<? } else { ?>
<span class="lasttitle">Running Stores</span>
<? } ?>
<? if ( $regionname ) { echo "&gt; " . $regionname; } ?>
<? if ( $statename ) { echo "&gt; " . $statename . " State"; } ?>
<? if ($row[runshop_name]) { echo "&gt; " . $row[runshop_name]; } ?>
</div>

View File

@ -0,0 +1,116 @@
<?PHP
if (eregi("include", $_SERVER['SCRIPT_NAME'])) {
Header("Location: ".$site_url."/index.php"); die();
}
if(is_logged_in($user)){
$tagtext = "I shop here";
$actionlink = "individual.php?runshop_id=$row[runshop_id]&".get_sid();
}else{
$tagtext = "Log in to tag this shop";
$actionlink = "$forum_url/forum/?do=login&from=runshops";
$tagstatus = "no";
}
if(is_logged_in($user)){
//Get user's uid
$useruid = base64_decode($_SESSION['user_id']);
// is the current user the owner of the shop?
$runshop_submitted_by = FALSE;
if($useruid == $row[runshop_submitted_by]){
$runshop_submitted_by = TRUE;
}
$tagresults = mysql_query("SELECT runshop_shopper_tags FROM ".$prefix."Runshops WHERE runshop_id=$row[runshop_id]");
$tagrow = mysql_fetch_array($tagresults);
$tags = explode(",", $tagrow[runshop_shopper_tags]);
$profileresults = mysql_query("SELECT user_runshoptags FROM ".$prefix."User WHERE user_id='$useruid'") or die(mysql_error());
$profilerow = mysql_fetch_array($profileresults);
$profiletags = explode(",", $profilerow[user_runshoptags]);
if($_POST[status] == "tag"){
//tag the shop
if(array_search($useruid, $tags) == FALSE){
array_push($tags, $useruid);
}
$tags = implode(",", $tags);
mysql_query("UPDATE ".$prefix."Runshops SET runshop_shopper_tags='$tags' WHERE runshop_id=$row[runshop_id]") or die(mysql_error());
$tags = explode(",", $tags);
if(array_search($row[runshop_id], $profiletags) == FALSE){
array_push($profiletags, $row[runshop_id]);
}
$profiletags = implode(",", $profiletags);
mysql_query("UPDATE ".$prefix."User SET user_runshoptags='$profiletags' WHERE user_id='$useruid'") or die(mysql_error());
}else if($_POST[status] == "untag"){
//untag the shop
$key = array_search($useruid, $tags);
unset($tags[$key]);
$tags = implode(",", $tags);
mysql_query("UPDATE ".$prefix."Runshops SET runshop_shopper_tags='$tags' WHERE runshop_id=$row[runshop_id]") or die(mysql_error());
$tags = explode(",", $tags);
$key = array_search($row[runshop_id], $profiletags);
unset($profiletags[$key]);
$profiletags = implode(",", $profiletags);
mysql_query("UPDATE ".$prefix."User SET user_runshoptags='$profiletags' WHERE user_id=$useruid");
}
//Is the shop tagged already?
if(array_search($useruid, $tags) !== FALSE){
$racing = TRUE;
} else {
$racing = FALSE;
}
if($racing){
$tagstatus = "untag";
$tagtext = "Untag this shop";
} else {
$tagstatus = "tag";
$tagtext = "I shop here";
}
}
?>
<form action="<? echo $actionlink; ?>" method="post" style="display: inline;">
<input type="hidden" value="<? echo $tagstatus; ?>" name="status" />
<? if (is_logged_in($user)) { ?>
<input type="submit" value="<? echo $tagtext; ?>" class="btn" />
<? } else { ?>
<a href="<? echo $actionlink ?>" class="btn"><? echo $tagtext; ?></a>
<? } ?>
</form>
<form method="post" action="<? echo "individual.php?runshop_id=$row[runshop_id]#tagged"; ?>" style="display: inline;">
<input type="submit" value="Who shops here?" class="btn" />
</form>
<?
// begin is is_logged_in check
if(is_logged_in($user)) { ?>
<form method="post" action="<? echo "wiki_edit.php?runshop_id=$row[runshop_id]"; ?>" style="display: inline;">
<input type="submit" value="Edit this shop (wiki)" class="btn" />
</form>
<? }
// end is_logged_in check
//begin is_admin check
if(is_admin()) {
?>
<form method="post" action="delete_X.php" style="display: inline;">
<input type="hidden" name="runshop_id" value="<? echo($row[runshop_id]); ?>" />
<input type="submit" value="Delete this shop" class="btn" onclick="return confirm('Are you sure you want to DELETE this shop?');" />
</form>
<?
//Get user's uid
$testresults = mysql_query("SELECT user_username FROM ".$prefix."User WHERE user_id='$row[runshop_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>");
}
// end is_admin check
?>

View File

@ -0,0 +1,27 @@
<?PHP
if (eregi("include", $_SERVER['SCRIPT_NAME'])) {
Header("Location: ".$site_url."/index.php"); die();
}
?>
<? $xmlURL = "http://www.slowtwitch.com/googlemaps/runshops_xml.php" ?>
<body id="home" <? if (eregi("index.php", $_SERVER['SCRIPT_NAME'])) { echo ("onload=\"initializeAllMap('$xmlURL')\""); } ?>>
<? include("../db_templates/fb_sdk.html"); ?>
<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>
<? include "../db_templates/common_nav.html"; ?>
<?
include("include_status.php");
?>
<?
include("include_navigation.php");
?>

View File

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

View File

@ -0,0 +1,14 @@
<?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 Running Store 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"); ?>
</head>

View File

@ -0,0 +1,384 @@
<p>
Please confirm your shop information. If everything is correct, click the submit button. Otherwise, you may click the edit button to change your shop information before submitting.
</p>
<h2><? echo stripslashes($_POST[runshop_name]); ?></h2>
<?$nametagmod = trim(strtolower(str_replace(" ","",$_POST[runshop_name])));?>
<div class="dtable form">
<div class="drow">
<div class="dcell name">Store Name</div>
<div class="dcell divider"></div>
<div class="dcell value"><? echo stripslashes($_POST[runshop_name]); ?></div>
</div>
<div class="drow">
<div class="dcell name">Address </div>
<div class="dcell divider"></div>
<div class="dcell value"><? echo stripslashes(htmlspecialchars($_POST[runshop_address])); ?></div>
</div>
<div class="drow">
<div class="dcell name">Address 2</div>
<div class="dcell divider"></div>
<div class="dcell value"><? echo stripslashes(htmlspecialchars($_POST[runshop_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[runshop_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[runshop_state])); ?></div>
</div>
<div class="drow">
<div class="dcell name">Zip</div>
<div class="dcell divider"></div>
<div class="dcell value"><? echo stripslashes(htmlspecialchars($_POST[runshop_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[runshop_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[runshop_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[runshop_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[runshop_website]; ?>" target="_blank"><? echo $_POST[runshop_website]; ?></a></div>
</div>
<div class="drow">
<div class="dcell name">Cart</div>
<div class="dcell divider"></div>
<div class="dcell value"><? if ($_POST[runshop_cart] == 0) { echo ("No"); } else { echo ("Yes"); } ?></div>
</div>
<div class="drow">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
for ($i = 0; $i < 10; $i++) echo("*");
echo (" TECHNOLOGY, COMMUNITY &amp; EDUCATION ");
for ($i = 0; $i < 10; $i++) echo("*");
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Key Tri-Specific Contact(s)</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? if ($_POST[runshop_contact] == 0) { echo "None"; } else { echo "Yes, Their Names - "; echo stripslashes($_POST[runshop_contact_names]); } ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Diagnostic Equipment</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
if ($_POST[runshop_diagnostics]) {
$implosion = implode(",", $_POST[runshop_diagnostics]);
$sql = ("SELECT * FROM ".$prefix."RunshopsDiagnostics WHERE diagnostic_id IN ($implosion) ORDER BY diagnostic_name ASC");
//echo $sql;
$list = mysql_query($sql) or die(mysql_error());
$diagnostic_list = "";
while ($fetch = mysql_fetch_array($list)) {
$diagnostic_list = $diagnostic_list."$fetch[diagnostic_name], ";
}
$diagnostic_list = rtrim($diagnostic_list, ', ');
echo $diagnostic_list;
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
for ($i = 0; $i < 25; $i++) echo("*");
echo (" BRANDS ");
for ($i = 0; $i < 25; $i++) echo("*");
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Shoes</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
if ($_POST[runshop_shoes]) {
$implosion = implode(",", $_POST[runshop_shoes]);
$sql = ("SELECT * FROM ".$prefix."RunshopsShoes WHERE shoe_id IN ($implosion) ORDER BY shoe_name ASC");
//echo $sql;
$list = mysql_query($sql) or die(mysql_error());
$shoe_list = "";
while ($fetch = mysql_fetch_array($list)) {
$shoe_list = $shoe_list."$fetch[shoe_name], ";
}
$shoe_list = rtrim($shoe_list, ', ');
echo $shoe_list;
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Socks</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
if ($_POST[runshop_socks]) {
$implosion = implode(",", $_POST[runshop_socks]);
$sql = ("SELECT * FROM ".$prefix."RunshopsSocks WHERE sock_id IN ($implosion) ORDER BY sock_name ASC");
//echo $sql;
$list = mysql_query($sql) or die(mysql_error());
$sock_list = "";
while ($fetch = mysql_fetch_array($list)) {
$sock_list = $sock_list."$fetch[sock_name], ";
}
$sock_list = rtrim($sock_list, ', ');
echo $sock_list;
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Run Focused Apparel</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
if ($_POST[runshop_apparel_run]) {
$implosion = implode(",", $_POST[runshop_apparel_run]);
$sql = ("SELECT * FROM ".$prefix."RunshopsApparelRun WHERE apparel_run_id IN ($implosion) ORDER BY apparel_run_name ASC");
//echo $sql;
$list = mysql_query($sql) or die(mysql_error());
$apparel_run_list = "";
while ($fetch = mysql_fetch_array($list)) {
$apparel_run_list = $apparel_run_list."$fetch[apparel_run_name], ";
}
$apparel_run_list = rtrim($apparel_run_list, ', ');
echo $apparel_run_list;
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Tri-Focused Apparel</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
if ($_POST[runshop_apparel_tri]) {
$implosion = implode(",", $_POST[runshop_apparel_tri]);
$sql = ("SELECT * FROM ".$prefix."RunshopsApparelTri WHERE apparel_tri_id IN ($implosion) ORDER BY apparel_tri_name ASC");
//echo $sql;
$list = mysql_query($sql) or die(mysql_error());
$apparel_tri_list = "";
while ($fetch = mysql_fetch_array($list)) {
$apparel_tri_list = $apparel_tri_list."$fetch[apparel_tri_name], ";
}
$apparel_tri_list = rtrim($apparel_tri_list, ', ');
echo $apparel_tri_list;
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Swim Gear</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
if ($_POST[runshop_swimgear]) {
$implosion = implode(",", $_POST[runshop_swimgear]);
$sql = ("SELECT * FROM ".$prefix."ResourceSwimgear WHERE swimgear_id IN ($implosion) ORDER BY swimgear_name ASC");
//echo $sql;
$list = mysql_query($sql) or die(mysql_error());
$swimgear_list = "";
while ($fetch = mysql_fetch_array($list)) {
$swimgear_list = $swimgear_list."$fetch[swimgear_name], ";
}
$swimgear_list = rtrim($swimgear_list, ', ');
echo $swimgear_list;
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Wetsuits</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
if ($_POST[runshop_wetsuits]) {
$implosion = implode(",", $_POST[runshop_wetsuits]);
$sql = ("SELECT * FROM ".$prefix."ResourceWetsuit WHERE wetsuit_id IN ($implosion) ORDER BY wetsuit_name ASC");
//echo $sql;
$list = mysql_query($sql) or die(mysql_error());
$wetsuit_list = "";
while ($fetch = mysql_fetch_array($list)) {
$wetsuit_list = $wetsuit_list."$fetch[wetsuit_name], ";
}
$wetsuit_list = rtrim($wetsuit_list, ', ');
echo $wetsuit_list;
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<? for ($i = 0; $i < 60; $i++) echo("*"); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Store Hours</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo stripslashes(htmlspecialchars($_POST[runshop_hours])); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Runs &amp; Classes</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo strip_tags(stripslashes($_POST[runshop_classes])) ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Shop Info</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo strip_tags(stripslashes($_POST[runshop_info])) ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Directions</div>
<div class="dcell divider"></div>
<div class="dcell value">
<? echo strip_tags(stripslashes($_POST[runshop_directions])); ?>
</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="runshop_name" value="<? echo stripslashes(htmlspecialchars($_POST[runshop_name])); ?>">
<input type="hidden" name="runshop_address" value="<? echo stripslashes(htmlspecialchars($_POST[runshop_address])); ?>">
<input type="hidden" name="runshop_address_two" value="<? echo stripslashes(htmlspecialchars($_POST[runshop_address_two])); ?>">
<input type="hidden" name="runshop_city" value="<? echo stripslashes(htmlspecialchars($_POST[runshop_city])); ?>">
<input type="hidden" name="runshop_state" value="<? echo $_POST[runshop_state]; ?>">
<input type="hidden" name="runshop_zip" value="<? echo stripslashes(htmlspecialchars($_POST[runshop_zip])); ?>">
<input type="hidden" name="runshop_phone" value="<? echo stripslashes(htmlspecialchars($_POST[runshop_phone])); ?>">
<input type="hidden" name="runshop_fax" value="<? echo stripslashes(htmlspecialchars($_POST[runshop_fax])); ?>">
<input type="hidden" name="runshop_email" value="<? echo stripslashes(htmlspecialchars($_POST[runshop_email])); ?>">
<input type="hidden" name="runshop_website" value="<? echo $_POST[runshop_website]; ?>">
<input type="hidden" name="runshop_cart" value="<? echo $_POST[runshop_cart]; ?>">
<input type="hidden" name="runshop_contact" value="<? echo $_POST[runshop_contact]; ?>">
<input type="hidden" name="runshop_contact_names" value="<? echo stripslashes(htmlspecialchars($_POST[runshop_contact_names])); ?>">
<input type="hidden" name="runshop_diagnostics" value="<? echo(implode(',', $_POST[runshop_diagnostics])); ?>">
<input type="hidden" name="runshop_shoes" value="<? echo(implode(',', $_POST[runshop_shoes])); ?>">
<input type="hidden" name="runshop_swimgear" value="<? echo(implode(',', $_POST[runshop_swimgear])); ?>">
<input type="hidden" name="runshop_wetsuits" value="<? echo(implode(',', $_POST[runshop_wetsuits])); ?>">
<input type="hidden" name="runshop_socks" value="<? echo(implode(',', $_POST[runshop_socks])); ?>">
<input type="hidden" name="runshop_apparel_run" value="<? echo(implode(',', $_POST[runshop_apparel_run])); ?>">
<input type="hidden" name="runshop_apparel_tri" value="<? echo(implode(',', $_POST[runshop_apparel_tri])); ?>">
<input type="hidden" name="runshop_hours" value="<? echo stripslashes(htmlspecialchars($_POST[runshop_hours])); ?>">
<input type="hidden" name="runshop_classes" value="<? echo stripslashes(htmlspecialchars($_POST[runshop_classes])); ?>">
<input type="hidden" name="runshop_info" value="<? echo stripslashes(htmlspecialchars($_POST[runshop_info])); ?>">
<input type="hidden" name="runshop_directions" value="<? echo stripslashes(htmlspecialchars($_POST[runshop_directions])); ?>">
<? // need to temporary set the field as being valid ?>
<input type="hidden" name="runshop_valid" value="1">
<input type="hidden" name="edit_shop" value="1">
<input type="hidden" name="confirm_entry" value="1">
<? if(isset($_POST[new_shop])){ ?>
This data will be saved as a NEW RETAILER.
<input type="hidden" name="new_shop" value="1" />
<input type="hidden" name="runshop_submitted_by" value="<? echo($_POST[edited_by]); ?>" />
<? } else { ?>
This data will be saved as a modification to the EXISTING RETAILER.
<input type="hidden" name="save_changes" value="1" />
<input type="hidden" name="edited_by" value="<? echo($_POST[edited_by]); ?>">
<input type="hidden" name="runshop_submitted_by" value="<? echo($_POST[runshop_submitted_by]); ?>" />
<input type="hidden" name="runshop_id" value="<? echo($_POST[runshop_id]); ?>" />
<? } ?>
<br><input type="submit" name="submit" value="Submit Info" class="btn float-left" style="margin-right: 5px;"/>
</form>
<form action="wiki_edit.php" method="post">
<input type="hidden" name="runshop_name" value="<? echo stripslashes(htmlspecialchars($name)); ?>">
<input type="hidden" name="runshop_address" value="<? echo stripslashes(htmlspecialchars($address)); ?>">
<input type="hidden" name="runshop_address_two" value="<? echo stripslashes(htmlspecialchars($address_two)); ?>">
<input type="hidden" name="runshop_city" value="<? echo stripslashes(htmlspecialchars($city)); ?>">
<input type="hidden" name="runshop_state" value="<? echo $state; ?>">
<input type="hidden" name="runshop_zip" value="<? echo stripslashes(htmlspecialchars($zip)); ?>">
<input type="hidden" name="runshop_phone" value="<? echo stripslashes(htmlspecialchars($phone)); ?>">
<input type="hidden" name="runshop_fax" value="<? echo stripslashes(htmlspecialchars($fax)); ?>">
<input type="hidden" name="runshop_email" value="<? echo stripslashes(htmlspecialchars($email)); ?>">
<input type="hidden" name="runshop_website" value="<? echo $website; ?>">
<input type="hidden" name="runshop_cart" value="<? echo $cart; ?>">
<input type="hidden" name="runshop_contact" value="<? echo $contact; ?>">
<input type="hidden" name="runshop_contact_names" value="<? echo stripslashes(htmlspecialchars($contact_names)); ?>">
<input type="hidden" name="runshop_diagnostics" value="<? echo(implode(',', $diagnostics)); ?>">
<input type="hidden" name="runshop_shoes" value="<? echo(implode(',', $shoes)); ?>">
<input type="hidden" name="runshop_swimgear" value="<? echo(implode(',', $swimgear)); ?>">
<input type="hidden" name="runshop_wetsuits" value="<? echo(implode(',', $wetsuits)); ?>">
<input type="hidden" name="runshop_socks" value="<? echo(implode(',', $socks)); ?>">
<input type="hidden" name="runshop_apparel_run" value="<? echo(implode(',', $apparel_run)); ?>">
<input type="hidden" name="runshop_apparel_tri" value="<? echo(implode(',', $apparel_tri)); ?>">
<input type="hidden" name="runshop_hours" value="<? echo stripslashes(htmlspecialchars($hours)); ?>">
<input type="hidden" name="runshop_classes" value="<? echo stripslashes(htmlspecialchars($classes)); ?>">
<input type="hidden" name="runshop_info" value="<? echo stripslashes(htmlspecialchars($info)); ?>">
<input type="hidden" name="runshop_directions" value="<? echo stripslashes(htmlspecialchars($directions)); ?>">
<input type="hidden" name="edit_return" value="1">
<? // need to temporary set the field as being valid ?>
<input type="hidden" name="runshop_valid" value="1">
<input type="hidden" name="runshop_id" value="<? echo($id); ?>" />
<input type="hidden" name="runshop_submitted_by" value="<? echo $submitted_by; ?>">
<input type="submit" name="submit" value="Edit Information" class="btn float-left">
</form>
</div>
</div>
</div>

View File

@ -0,0 +1,71 @@
<?PHP
if (eregi("include", $_SERVER['SCRIPT_NAME'])) {
Header("Location: ".$site_url."/index.php"); die();
}
$sqlregionlist = "SELECT gtr.regionlong AS regionlong, gtr.regionid AS regionid, gtr.regionname AS regionname, gts.statetag AS statetag, gts.statelong AS statelong, COUNT(gr.runshop_id) AS numshops
FROM ".$prefix."ResourceStates AS gts
LEFT JOIN ".$prefix."Runshops AS gr
ON gts.statetag = gr.runshop_state_tag AND gr.runshop_valid = 1
LEFT JOIN ".$prefix."ResourceRegions AS gtr
ON gts.regionid = gtr.regionid
GROUP BY gtr.regionlong, gts.statetag ORDER BY gtr.regionlong ASC";
$resultregionlist = mysql_query($sqlregionlist);
?>
<div class="widget">
<h2>Choose Listing</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 != '') {
$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>\n");
}
$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[numshops])</option>";
$tempstring = $tempstring. "<a href='$site_url/statelist.php?state=$rowregionlist[statetag]".get_sid()."' class='lhdr' title='$rowregionlist[statelong]'>$rowregionlist[statelong] ($rowregionlist[numshops])</a>\n";
$regioncount += $rowregionlist[numshops];
}
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 Run Shops</a> <span class="sprite-magnify">&nbsp;</span>
</div>
</div>
</div>

View File

@ -0,0 +1,4 @@
<div class="mobile tablet">
<select id="region_state" class="region-select" onchange="window.location = this.value;"><option value="<? echo $site_url ?>">Select a Region/State</option><? echo $region_dropdown ?></select>
<div class="widget-divider"></div>
</div>

View File

@ -0,0 +1,14 @@
<?
$selected_local = 'runshops';
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,44 @@
<?PHP
if (eregi("include", $_SERVER['SCRIPT_NAME'])) {
Header("Location: ".$site_url."/index.php"); die();
}
function tut_stars($tut_rating){
if((($tut_rating >= 0)or($tut_rating == 0)) && ($tut_rating <= 0.50)){
echo "Not Rated";
}
if((($tut_rating >= 0.50)or($tut_rating == 0.50)) && ($tut_rating <= .99)){
echo "<img src=\"/images/stars/05o5.gif\" width=\"50\" height=\"11\">";
}
if((($tut_rating >= 1.00)or($tut_rating == 1.50)) && ($tut_rating <= 1.49)){
echo "<img src=\"/images/stars/1o5.gif\" width=\"50\" height=\"11\">";
}
if((($tut_rating >= 1.50)or($tut_rating == 1.50)) && ($tut_rating <= 1.99)){
echo "<img src=\"/images/stars/15o5.gif\" width=\"50\" height=\"11\">";
}
if((($tut_rating >= 2.00)or($tut_rating == 2.00)) && ($tut_rating <= 2.49)){
echo "<img src=\"/images/stars/2o5.gif\" width=\"50\" height=\"11\">";
}
if((($tut_rating >= 2.50)or($tut_rating == 2.50)) && ($tut_rating <= 2.99)){
echo "<img src=\"/images/stars/25o5.gif\" width=\"50\" height=\"11\">";
}
if((($tut_rating >= 3.00)or($tut_rating == 3.00)) && ($tut_rating <= 3.49)){
echo "<img src=\"/images/stars/3o5.gif\" width=\"50\" height=\"11\">";
}
if((($tut_rating >= 3.50)or($tut_rating == 3.50)) && ($tut_rating <= 3.99)){
echo "<img src=\"/images/stars/35o5.gif\" width=\"50\" height=\"11\">";
}
if((($tut_rating >= 4.00)or($tut_rating == 4.00)) && ($tut_rating <= 4.49)){
echo "<img src=\"/images/stars/4o5.gif\" width=\"50\" height=\"11\">";
}
if((($tut_rating >= 4.50)or($tut_rating == 4.50)) && ($tut_rating <= 4.99)){
echo "<img src=\"/images/stars/45o5.gif\" width=\"50\" height=\"11\">";
}
if($tut_rating == 5.0){
echo "<img src=\"/images/stars/5o5.gif\" width=\"50\" height=\"11\">";
}
}
?>

View File

@ -0,0 +1,10 @@
<? if (is_admin()) {
$unvalid_count = mysql_num_rows(mysql_query("SELECT * FROM ".$prefix.$main_table." WHERE ".$field_lead."valid = 0"));
echo("<div><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></div>");
echo("<div class='widget-divider'></div>");
} ?>

View File

@ -0,0 +1,20 @@
<div class="list-block grid">
<div class="col-1-1 clearfix">
<h3 class="float-left"><a href="<? echo "individual.php?runshop_id=$row[runshop_id]"; ?>"><? echo $row[runshop_name]; ?></a></h3>
</div>
<div class="col-1-2">
<?
echo ("$row[runshop_address]");
if ($row[runshop_address_two]) { echo ("<br />$row[runshop_address_two]"); }
echo("<br />$row[runshop_city], $row[runshop_state] $row[runshop_zip]");
?>
<br />Phone: <? echo $row[runshop_phone] ?>
<br />Fax: <? echo $row[runshop_fax] ?>
</div>
<div class="col-1-2">
Email: <? echo "<a href='mailto:$row[runshop_email]'>$row[runshop_email]</a>"; ?><br/>
Website: <? echo "<a href='$row[runshop_website]' target='_blank'>$row[runshop_website]</a>"; ?><br/>
<? if ($row[runshop_cart] == 1) { echo ("**eCommerce Shopping Cart**<br />"); } ?>
<a href="<? echo "individual.php?runshop_id=$row[runshop_id]"; ?>">More info &gt;</a>
</div>
</div>

138
site/runshops/index.php Normal file
View File

@ -0,0 +1,138 @@
<?PHP include("config.php");
// set the page title
$pagetitle = "Triathlon & Multisport Running Stores";
// set meta tags
$meta_keywords = "triathlon, trifind, duathlon";
$meta_description = "Are you trying to find triathlon running stores in near your area? You can browse all triathlon running stores organized by states, to find which retail locations you want to patronize.";
?>
<? 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 section-has-widgets section-static remove-sidebar clearfix">
<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">Running Stores</h1>
<? if (is_logged_in($user)) { ?>
<a href="<? echo $site_url . '/add.php' ?>" class="btn btn-white float-right">Add Retailer</a>
<? } ?>
<hr class="line" />
<? include("include_region_list.php"); ?>
<div class="map-container">
<div id="map" class="map" data-name="runshop" data-json="<? echo $main_site_url ?>/googlemaps/json/runshop.json"></div><!--xml relative path from js folder -->
</div>
<?
$numstores = mysql_num_rows(mysql_query("SELECT runshop_id FROM ".$prefix."Runshops WHERE runshop_valid=1"));
?>
<h3>Welcome to Slowtwitch.com's North American Multisport Running Store Database</h3>
<p><? echo($numstores) ?> running stores and counting. This collection of running stores is the most complete and comprehensive
selection of tri-specific running stores in North America. The purpose is to
introduce triathletes to the dealers they should know, and to present as
much pertinent information about them as possible.
</p>
<h3>Searching the database</h3>
<p>
Our Advanced Search is very potent, and will help you drill down to that set
of runnning stores conforming to a specific purpose you have in mind. For
example, you could search for those stores that have a motion capture system; and a treadmill; and that carry Nike and Zoot; and that are in either Wisconsin or
Illinois. Or you could search for stores in Georgia that stock Quintana Roo
wetsuits. The search parameters are yours to choose.
</p>
<h3>Browsing the database</h3>
<p>
You do not need to log in to do this. You'll find a list of running stores 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 running stores in it. If you want to see running stores 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 local running store</h3>
<p>
When you see your local running store listed here, you may click the "I SHOP
HERE" button. Your User Name will be added to the store's list of customers,
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 you patronize this store.
</p>
<div class="advert float-left">
<? include($common_path . "/ads/ad_300x250_roadblocks.html"); ?>
</div>
<h3>How to enter a running store</h3>
<p>
You must be a registered user to add a running store 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 running stores to our database. However, this
is not like adding a race to our calendar. There are a lot of technical
elements to this entry, and almost certainly the running store will want to do this on their own. Therefore, it is wisest not to make an entry on behalf of
your preferred running store, but to urge them to do so themselves.
<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 SHOP button to begin adding to the database.
<br /><br />
2. Once you SUBMIT your store, 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 store, 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 store registration as a way to spam
our database.
</p>
<h3>How to edit published information about a running store</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 running store</h3>
<p>
Any registered user may make a comment on a running store. These comments are subject to validation by an administrator before being published.
</p>
<h3>Global run shop map</h3>
<p>
The map below shows the location of all registered Slowtwitch running shops 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 running shop 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>

View File

@ -0,0 +1,297 @@
<?PHP
include("config.php");
require_once("rating/classes/include.all.php");
$runshop_idhere = intval(mysql_escape_string($_GET[runshop_id]));
$results = mysql_query("SELECT * FROM ".$prefix."Runshops WHERE runshop_id='".$runshop_idhere."' LIMIT 1");
$row = mysql_fetch_array($results);
if (!$row){header('Location: '.$site_url.'/?error=invalid_id');}
if($row[runshop_valid] == 0) {
if(!is_admin()){
header('Location: '.$site_url);
exit();
}
}
// set the page title
$pagetitle = $row[runshop_name];
// set meta tags
$meta_keywords = "triathlon, ".$row[runshop_name].", ".$row[runshop_state]." running store";
$meta_description = "Considering shopping at ".$row[runshop_name]."? Here is all of the information about this running store.";
?>
<? 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[runshop_state]); ?>
<? include("include_sidebar.php"); ?>
</div>
<div class="content content-has-widgets">
<div class="grid">
<div class="clearfix">
<h1 class="float-left">Running Stores</h1>
<? if ($user) { ?>
<form method="post" action="wiki_edit.php?retailer_id=<? echo $row[runshop_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("include_region_list.php"); ?>
<div class="details grid">
<div class="col-9-12">
<h2><? echo stripslashes(stripslashes($row[runshop_name])) ; 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[runshop_address])); ?><br />
<? if ( $row[runshop_address_two] ) { echo stripslashes(htmlspecialchars($row[runshop_address_two]) . "<br />"); } ?>
<? echo stripslashes(htmlspecialchars($row[runshop_city])); ?>, <? echo stripslashes(htmlspecialchars($row[runshop_state])); ?> <? echo stripslashes(htmlspecialchars($row[runshop_zip])); ?><br />
Phone: <? echo stripslashes(htmlspecialchars($row[runshop_phone])); ?><br />
Fax: <? echo stripslashes(htmlspecialchars($row[runshop_fax])); ?>
</div>
<div class="col-6-12 contact">
Email: <a href="mailto:<? echo $row[runshop_email]; ?>"><? echo stripslashes(htmlspecialchars($row[runshop_email])); ?></a><br />
<span class="briefy-b">Website: <a href="<? echo $row[runshop_website]; ?>" target="_blank"><? echo stripslashes(htmlspecialchars($row[runshop_website])); ?></a></span>
</div>
<div class="clearfix"></div>
<? 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."RunshopsEdits WHERE runshop_id_fk = '".intval(mysql_escape_string($_GET[runshop_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>
<? } ?>
<br />
<div class="col-1-1">
<? include("include_buttons.php"); ?>
</div>
<div class="col-1-1 detail-block">
<h3>Key Tri-Specific Contact(s)</h3>
<div class="highlight-block">
<? if ($row[runshop_contact] == 0) { echo "None"; } else { echo "Yes, Their Names - "; echo stripslashes($row[runshop_contact_names]); } ?>
</div>
</div>
<div class="col-1-1 detail-block">
<h3>Diagnostic Equipment</h3>
<div class="highlight-block">
<?
$row[runshop_diagnostics] = ltrim(rtrim($row[runshop_diagnostics], ", "), ", ");
if ($row[runshop_diagnostics]) {
$sql = ("SELECT * FROM ".$prefix."RunshopsDiagnostics WHERE diagnostic_id IN ($row[runshop_diagnostics]) ORDER BY diagnostic_name ASC");
$fetch = mysql_query($sql) or die(mysql_error());
$diagnostic_list = "";
while ($list = mysql_fetch_array($fetch)) {
$diagnostic_list = $diagnostic_list."$list[diagnostic_name], ";
}
$diagnostic_list = rtrim($diagnostic_list, ', ');
}
if ($diagnostic_list) {echo $diagnostic_list;} else {echo "None";}
?>
</div>
</div>
<div class="col-1-1 detail-block">
<h3>Brands</h3>
<div class="highlight-block">
<strong>Running Shoes:</strong>
<?
$row[runshop_shoes] = ltrim(rtrim($row[runshop_shoes], ", "), ", ");
if ($row[runshop_shoes]) {
$sql = ("SELECT * FROM ".$prefix."RunshopsShoes WHERE shoe_id IN ($row[runshop_shoes]) ORDER BY shoe_name ASC");
$fetch = mysql_query($sql) or die(mysql_error());
$shoe_list = "";
while ($list = mysql_fetch_array($fetch)) {
$shoe_list = $shoe_list."$list[shoe_name], ";
}
$shoe_list = rtrim($shoe_list, ', ');
if ($shoe_list) {echo $shoe_list;} else {echo "None";}
?><br />
<strong>Socks:</strong>
<?
$row[runshop_socks] = ltrim(rtrim($row[runshop_socks], ", "), ", ");
$sql = ("SELECT * FROM ".$prefix."RunshopsSocks WHERE sock_id IN ($row[runshop_socks]) ORDER BY sock_name ASC");
$fetch = mysql_query($sql) or die(mysql_error());
$sock_list = "";
while ($list = mysql_fetch_array($fetch)) {
$sock_list = $sock_list."$list[sock_name], ";
}
$sock_list = rtrim($sock_list, ', ');
}
if ($sock_list) {echo $sock_list;} else {echo "None";}
?><br />
<strong>Run Focused Apparel:</strong>
<?
$row[runshop_apparel_run] = ltrim(rtrim($row[runshop_apparel_run], ", "), ", ");
if ($row[runshop_apparel_run]) {
$sql = ("SELECT * FROM ".$prefix."RunshopsApparelRun WHERE apparel_run_id IN ($row[runshop_apparel_run]) ORDER BY apparel_run_name ASC");
$fetch = mysql_query($sql) or die(mysql_error());
$apparel_run_list = "";
while ($list = mysql_fetch_array($fetch)) {
$apparel_run_list = $apparel_run_list."$list[apparel_run_name], ";
}
$apparel_run_list = rtrim($apparel_run_list, ', ');
}
if ($apparel_run_list) {echo $apparel_run_list;} else {echo "None";}
?><br />
<strong>Tri Focused Apparel:</strong>
<?
$row[runshop_apparel_tri] = ltrim(rtrim($row[runshop_apparel_tri], ", "), ", ");
if ($row[runshop_apparel_tri]) {
$sql = ("SELECT * FROM ".$prefix."RunshopsApparelTri WHERE apparel_tri_id IN ($row[runshop_apparel_tri]) ORDER BY apparel_tri_name ASC");
$fetch = mysql_query($sql) or die(mysql_error());
$apparel_tri_list = "";
while ($list = mysql_fetch_array($fetch)) {
$apparel_tri_list = $apparel_tri_list."$list[apparel_tri_name], ";
}
$apparel_tri_list = rtrim($apparel_tri_list, ', ');
}
if ($apparel_tri_list) {echo $apparel_tri_list;} else {echo "None";}
?><br />
<strong>Swim Gear:</strong>
<?
$row[runshop_swimgear] = ltrim(rtrim($row[runshop_swimgear], ", "), ", ");
if ($row[runshop_swimgear]) {
$sql = ("SELECT * FROM ".$prefix."ResourceSwimgear WHERE swimgear_id IN ($row[runshop_swimgear]) ORDER BY swimgear_name ASC");
$fetch = mysql_query($sql) or die(mysql_error());
$swimgear_list = "";
while ($list = mysql_fetch_array($fetch)) {
$swimgear_list = $swimgear_list."$list[swimgear_name], ";
}
$swimgear_list = rtrim($swimgear_list, ', ');
}
if ($swimgear_list) {echo $swimgear_list;} else {echo "None";}
?><br />
<strong>Wetsuits:</strong>
<?
$row[runshop_wetsuits] = ltrim(rtrim($row[runshop_wetsuits], ", "), ", ");
if ($row[runshop_wetsuits]) {
$sql = ("SELECT * FROM ".$prefix."ResourceWetsuit WHERE wetsuit_id IN ($row[runshop_wetsuits]) ORDER BY wetsuit_name ASC");
$fetch = mysql_query($sql) or die(mysql_error());
$wetsuit_list = "";
while ($list = mysql_fetch_array($fetch)) {
$wetsuit_list = $wetsuit_list."$list[wetsuit_name], ";
}
$wetsuit_list = rtrim($wetsuit_list, ', ');
}
if ($wetsuit_list) {echo $wetsuit_list;} else {echo "None";}
?><br />
</div>
</div>
<div class="col-1-1 detail-block">
<h3>General Information</h3>
<div class="highlight-block">
<strong>Store Hours:</strong> <? echo stripslashes(htmlspecialchars($row[runshop_hours])); ?><br />
<strong>Runs &amp; Classes:</strong> <? echo stripslashes(stripslashes($row[runshop_classes])) ?><br />
<p><strong>Shop Info</strong> <? echo stripslashes(stripslashes($row[runshop_info])) ?></p>
<p><strong>Directions:</strong> <? echo stripslashes(stripslashes($row[runshop_directions])) ?></p>
</div>
</div>
<div class="col-1-1">
<div id="map" class="map map-single" data-name="single" data-category="runshop" data-lat="<? echo $row[runshop_lat] ?>" data-lng="<? echo $row[runshop_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 Shops Here?</h3>
<div class="highlight-block">
<!-- BEGIN LIST OF TAGGED USERS -->
<?
$testresults = mysql_query("SELECT runshop_shopper_tags FROM ".$prefix."Runshops WHERE runshop_id=$row[runshop_id]");
$testrow = mysql_fetch_array($testresults);
$tags = explode(",", $testrow[runshop_shopper_tags]);
$numcount = count($tags) - 1;
if($numcount == 0){ $phrase = "No users have tagged this shop yet."; }
else if($numcount == 1){ $phrase = "There is 1 user who has tagged this shop:"; }
else { $phrase = "There are $numcount users who have tagged this shop: "; }
?>
<a name="tagged"></a><? echo $phrase; ?>
<?
$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 ", "; }
echo "<a href=\"http://forum.slowtwitch.com/gforum.cgi?username=$temprow[user_username]&session=".$_SESSION['session_id']."&from=runshops\">$temprow[user_username]</a>";
}
$i++;
}
?>
<!-- END OF LIST OF TAGGED USERS -->
</div>
</div>
<div class="col-1-1 detail-block">
<?
$testresults = mysql_query("SELECT * FROM ".$prefix."RunshopsEditors WHERE runshop_id_fk=$row[runshop_id] ORDER BY edit_timestamp DESC");
$numcount = mysql_num_rows($testresults);
if($numcount == 0){ $phrase = "No updates have been made this running store yet."; }
else if($numcount == 1){ $phrase = "There has been 1 update to this running store:"; }
else{ $phrase = "There have been $numcount updates to this running store: "; }
?>
<div class="highlight-block">
<?
$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=runshops\">$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/runshops/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=runshops");
?>

View File

@ -0,0 +1,15 @@
<VirtualHost *>
ServerName forum.slowtwitch.com
DocumentRoot /srv/www/htdocs/trifind
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^/racereports/(.*)-([0-9]+).html$ /indivreport.php?report=$2
RewriteRule ^/racereports/page([0-9]+).html$ /racereports.php?page=$1
RewriteRule ^/editprofile/(.*).html$ /editprofile.php?username1=$1
RewriteRule ^/profiles/(.*).html$ /profile.php?username1=$1
RewriteRule ^/blogs/(.*)-([0-9]+).html$ /indivblog.php?blog=$2
RewriteRule ^/(.*)/(.*)-([0-9]+).html$ /individual.php?uid=$3
RewriteRule ^/state/(.*).html$ /statelist.php?state=$1
RewriteRule ^/blogs/page([0-9]+).html$ /blog.php?page=$1
RewriteRule ^/(.*).html$ /$1.php
</VirtualHost>

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: ".$site_url."/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,4 @@
<?php
header('Location: /');
exit;
?>

View File

@ -0,0 +1,4 @@
<?php
header('Location: /');
exit;
?>

View File

@ -0,0 +1,4 @@
<?php
header('Location: phpThumb.demo.demo.php');
exit;
?>

View File

@ -0,0 +1,278 @@
<?php
//////////////////////////////////////////////////////////////
/// phpThumb() by James Heinrich <info@silisoftware.com> //
// available at http://phpthumb.sourceforge.net ///
//////////////////////////////////////////////////////////////
/// //
// phpThumb.demo.check.php //
// James Heinrich <info@silisoftware.com> //
// //
// Configuration analyzer for phpThumb settings and server //
// settings that may affect phpThumb performance //
// Live demo is at http://phpthumb.sourceforge.net/demo/ //
// //
//////////////////////////////////////////////////////////////
$ServerInfo['gd_string'] = 'unknown';
$ServerInfo['gd_numeric'] = 0;
ob_start();
if (!@include_once('../phpthumb.functions.php')) {
ob_end_flush();
die('failed to include_once("../phpthumb.functions.php")');
}
if (!@include_once('../phpthumb.class.php')) {
ob_end_flush();
die('failed to include_once("../phpthumb.class.php")');
}
ob_end_clean();
$phpThumb = new phpThumb();
if (include_once('../phpThumb.config.php')) {
foreach ($PHPTHUMB_CONFIG as $key => $value) {
$keyname = 'config_'.$key;
$phpThumb->setParameter($keyname, $value);
}
}
$ServerInfo['gd_string'] = phpthumb_functions::gd_version(true);
$ServerInfo['gd_numeric'] = phpthumb_functions::gd_version(false);
$ServerInfo['im_version'] = $phpThumb->ImageMagickVersion();
$gd_info = gd_info();
?>
<html>
<head>
<title>phpThumb configuration analyzer</title>
<link rel="stylesheet" type="text/css" href="/style.css" title="style sheet">
</head>
<body bgcolor="#C5C5C5">
This demo analyzes your settings (phpThumb.config.php and server/PHP) for <a href="http://phpthumb.sourceforge.net"><b>phpThumb()</b></a>.<br>
<br>
<table border="1">
<tr><th colspan="8">&lt;-- bad to good --&gt;</th></tr>
<tr>
<td bgcolor="red">&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td bgcolor="orange">&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td bgcolor="yellow">&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td bgcolor="olive">&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td bgcolor="darkgreen">&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td bgcolor="green">&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td bgcolor="lightgreen">&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td bgcolor="lime">&nbsp;&nbsp;&nbsp;&nbsp;</td>
</tr>
</table>
<table border="1">
<?php
$versions['raw'] = array(
'latest' => phpthumb_functions::SafeURLread('http://phpthumb.sourceforge.net/?latestversion=1', $dummy),
'this' => $phpThumb->phpthumb_version,
);
foreach ($versions['raw'] as $key => $value) {
eregi('^([0-9\.]+)\-?(([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}))?', $value, $matches);
@list($huge, $major, $minor) = @explode('.', @$matches[1]);
@list($year, $month, $day, $hour, $min) = @$matches[3];
$versions['base'][$key] = $matches[1];
$versions['huge'][$key] = $huge;
$versions['major'][$key] = $major;
$versions['minor'][$key] = $minor;
$versions['stamp'][$key] = $matches[2];
$versions['year'][$key] = $year;
$versions['month'][$key] = $month;
$versions['day'][$key] = $day;
$versions['hour'][$key] = $hour;
$versions['min'][$key] = $min;
$versions['date'][$key] = @mktime($hour, $min, 0, $month, $day, $year);
}
$downloadlatest = 'Download the latest version from <a href="http://phpthumb.sourceforge.net">http://phpthumb.sourceforge.net</a>';
echo '<tr><th nowrap>Latest phpThumb version:</th><th>'.$versions['raw']['latest'].'</th><td>'.$downloadlatest.'</td></tr>';
echo '<tr><th nowrap>This phpThumb version:</th><th bgcolor="';
if (!$versions['base']['latest']) {
// failed to get latest version number
echo 'white';
$message = 'Latest version unknown.<br>'.$downloadlatest;
} elseif (phpthumb_functions::version_compare_replacement($versions['base']['this'], $versions['base']['latest'], '>')) {
// new than latest, must be beta version
echo 'lightblue';
$message = 'This must be a pre-release beta version. Please report bugs to <a href="mailto:info@silisoftware.com">info@silisoftware.com</a>';
} elseif (($versions['base']['latest'] == $versions['base']['this']) && ($versions['stamp']['this'] > $versions['stamp']['latest'])) {
// new than latest, must be beta version
echo 'lightblue';
$message = 'You must be using a pre-release beta version. Please report bugs to <a href="mailto:info@silisoftware.com">info@silisoftware.com</a>';
} elseif ($versions['base']['latest'] == $versions['base']['this']) {
// latest version
echo 'lime';
$message = 'You are using the latest released version.';
} elseif ($versions['huge']['latest'].$versions['major']['latest'] == $versions['huge']['this'].$versions['major']['this']) {
echo 'olive';
$message = 'One (or more) minor version(s) have been released since this version.<br>'.$downloadlatest;
} elseif (floatval($versions['huge']['latest'].str_pad($versions['major']['latest'], 2, '0', STR_PAD_LEFT)) < floatval($versions['huge']['this'].str_pad($t_major, 2, '0', STR_PAD_LEFT))) {
echo 'yellow';
$message = 'One (or more) major version(s) have been released since this version, you really should upgrade.<br>'.$downloadlatest;
} else {
echo 'orange';
$message = 'Fundamental changes have been made since this version.<br>'.$downloadlatest;
}
echo '">'.$phpThumb->phpthumb_version;
echo '</td><td>'.$message.'.<br></td></tr>';
echo '<tr><th>PHP version:</th><th bgcolor="';
if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=')) {
echo 'lime';
} elseif (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.3', '>=')) {
echo 'lightgreen';
} elseif (phpthumb_functions::version_compare_replacement(phpversion(), '4.2.0', '>=')) {
echo 'green';
} elseif (phpthumb_functions::version_compare_replacement(phpversion(), '4.1.0', '>=')) {
echo 'yellow';
} elseif (phpthumb_functions::version_compare_replacement(phpversion(), '4.0.6', '>=')) {
echo 'orange';
} else {
echo 'red';
}
echo '">'.phpversion();
echo '</td><td>PHP5 is ideal (support for numerous built-in filters which are much faster than my code).<br>PHP v4.3.2+ supports ImageSaveAlpha which is required for proper PNG/ICO output.<br>ImageRotate requires PHP v4.3.0+ (but buggy before v4.3.3).<br>EXIF thumbnail extraction requires PHP v4.2.0+.<br>Most things will work back to PHP v4.1.0, and mostly (perhaps buggy) back to v4.0.6, but no guarantees for any version older than that.</td></tr>';
echo '<tr><th>GD version:</th><th bgcolor="';
if ($ServerInfo['gd_numeric'] >= 2) {
if (eregi('bundled', @$ServerInfo['gd_string'])) {
echo 'lime';
} else {
echo 'yellow';
}
} elseif ($ServerInfo['im_version']) {
echo 'orange';
} else {
echo 'red';
}
echo '">'.@$ServerInfo['gd_string'];
echo '</td><td>GD2-bundled version is ideal.<br>GD2 (non-bundled) is second choice, but there are a number of bugs in the non-bundled version.<br>GD1 will also (mostly) work, at much-reduced image quality and several features disabled. phpThumb can perform basic resizing with ImageMagick only, even if GD is not available.</td></tr>';
echo '<tr><th>ImageMagick version:</th><th bgcolor="';
if ($ServerInfo['im_version']) {
echo 'lime';
} elseif (@$ServerInfo['gd_string']) {
echo 'yellow';
} else {
echo 'red';
}
echo '">'.($ServerInfo['im_version'] ? $ServerInfo['im_version'] : 'n/a');
echo '</td><td>ImageMagick is faster than GD, can process larger images without PHP memory_limit issues, can resize animated GIFs. phpThumb can perform basic resizing with ImageMagick only, even if GD is not available.</td></tr>';
echo '<tr><th>GD features:</th><th>';
$GDfeatures['red'] = array('JPG Support', 'PNG Support');
$GDfeatures['orange'] = array('GIF Read Support', 'GIF Create Support', 'FreeType Support');
foreach ($GDfeatures as $missingcolor => $features) {
foreach ($features as $dummy => $feature) {
echo '<div style="background-color: '.($gd_info[$feature] ? 'lime' : $missingcolor).';">'.htmlentities($feature).'</div>';
}
}
echo '</td><td>PNG support is required for watermarks, overlays, calls to ImageMagick and other internal operations.<br>JPG support is obviously quite useful, but ImageMagick can substitute<br>GIF read support can be bypassed with ImageMagick and/or internal GIF routines.<br>GIF create support can be bypassed with ImageMagick (if no filters are applied)<br>FreeType support is needed for TTF overlays.</td></tr>';
echo '<tr><th>GD extension "EXIF"</th><th bgcolor="';
if (extension_loaded('exif')) {
echo 'lime';
} elseif (@$ServerInfo['gd_string']) {
echo 'orange';
}
echo '">'.(extension_loaded('exif') ? 'TRUE' : 'FALSE');
echo '</td><td>EXIF extension required for auto-rotate images. Also required to extract EXIF thumbnail to use as source if source image is too large for PHP memory_limit and ImageMagick is unavailable.</td></tr>';
echo '<tr><th>magic_quotes_runtime:</th><th bgcolor="';
if (@ini_get('magic_quotes_runtime')) {
echo 'red';
} else {
echo 'lime';
}
echo '">'.$phpThumb->phpThumbDebugVarDump((bool) @get_magic_quotes_runtime());
echo '</td><td>This setting is evil. Turn it off.</td></tr>';
echo '<tr><th>magic_quotes_gpc:</th><th bgcolor="';
if (@ini_get('magic_quotes_runtime')) {
echo 'orange';
} else {
echo 'lime';
}
echo '">'.$phpThumb->phpThumbDebugVarDump((bool) @get_magic_quotes_gpc());
echo '</td><td>This setting is bad. Turn it off, if possible. phpThumb will attempt to work around it if it is enabled</td></tr>';
echo '<tr><th>safe_mode:</th><th bgcolor="';
if (@ini_get('safe_mode')) {
echo 'yellow';
} else {
echo 'lime';
}
echo '">'.$phpThumb->phpThumbDebugVarDump((bool) @ini_get('safe_mode'));
echo '</td><td>Best if off. Calls to ImageMagick will be disabled if on (limiting max image resolution, no animated GIF resize).</td></tr>';
echo '<tr><th>allow_url_fopen:</th><th bgcolor="';
if (@ini_get('allow_url_fopen')) {
echo 'lime';
} else {
echo 'yellow';
}
echo '">'.$phpThumb->phpThumbDebugVarDump((bool) @ini_get('allow_url_fopen'));
echo '</td><td>Best if on. HTTP source images will be unavailable if disabled and CURL is unavailable.</td></tr>';
echo '<tr><th>curl_version:</th><th bgcolor="';
if (function_exists('curl_version')) {
echo 'lime';
} else {
echo 'yellow';
}
echo '">'.(function_exists('curl_version') ? curl_version() : 'n/a') ;
echo '</td><td>Best if available. HTTP source images will be unavailable if CURL unavailable and <i>allow_url_fopen</i> is also disabled.</td></tr>';
echo '<tr><th>disable_functions:</th><th bgcolor="';
$disable_functions = @ini_get('disable_functions');
if (!$disable_functions) {
echo 'lime';
} else {
echo 'yellow';
}
echo '">'.eregi_replace('(shell_exec|system|passthru|exec)(,|$)', '<span style="background-color: red;">\\1</span>(\\2)', $disable_functions);
echo '</td><td>Best if nothing disabled. Calls to ImageMagick will be prevented if exec+system+shell_exec+passthru are disabled.</td></tr>';
echo '<tr><th>memory_limit:</th><th bgcolor="';
$memory_limit = @ini_get('memory_limit');
if (!$memory_limit) {
echo 'lime';
} elseif ($memory_limit >= 32) {
echo 'lime';
} elseif ($memory_limit >= 24) {
echo 'lightgreen';
} elseif ($memory_limit >= 16) {
echo 'green';
} elseif ($memory_limit >= 12) {
echo 'darkgreen';
} elseif ($memory_limit >= 8) {
echo 'olive';
} elseif ($memory_limit >= 4) {
echo 'yellow';
} elseif ($memory_limit >= 2) {
echo 'orange';
} else {
echo 'red';
}
echo '">'.($memory_limit ? $memory_limit : '<i>unlimited</i>');
echo '</td><td>The higher the better. Divide by 5 to get maximum megapixels of source image that can be thumbnailed (without ImageMagick).'.($memory_limit ? ' Your setting ('.$memory_limit.') allows images up to approximately '.number_format($memory_limit / 5, 1).' megapixels' : '').'</td></tr>';
?>
</table>
</body>
</html>

View File

@ -0,0 +1,249 @@
<?php
//////////////////////////////////////////////////////////////
/// phpThumb() by James Heinrich <info@silisoftware.com> //
// available at http://phpthumb.sourceforge.net ///
//////////////////////////////////////////////////////////////
/// //
// phpThumb.demo.demo.php //
// James Heinrich <info@silisoftware.com> //
// //
// Demo showing a wide variety of parameters that can be //
// passed to phpThumb.php //
// Live demo is at http://phpthumb.sourceforge.net/demo/ //
// //
//////////////////////////////////////////////////////////////
$ServerInfo['gd_string'] = 'unknown';
$ServerInfo['gd_numeric'] = 0;
ob_start();
if (!@include_once('../phpthumb.functions.php')) {
ob_end_flush();
die('failed to include_once("../phpthumb.functions.php")');
}
if (!@include_once('../phpthumb.class.php')) {
ob_end_flush();
die('failed to include_once("../phpthumb.class.php")');
}
ob_end_clean();
$phpThumb = new phpThumb();
if (include_once('../phpThumb.config.php')) {
foreach ($PHPTHUMB_CONFIG as $key => $value) {
$keyname = 'config_'.$key;
$phpThumb->setParameter($keyname, $value);
}
}
$ServerInfo['phpthumb_version'] = $phpThumb->phpthumb_version;
$ServerInfo['im_version'] = $phpThumb->ImageMagickVersion();;
$ServerInfo['gd_string'] = phpthumb_functions::gd_version(true);
$ServerInfo['gd_numeric'] = phpthumb_functions::gd_version(false);
unset($phpThumb);
?>
<html>
<head>
<title>Demo of phpThumb() - thumbnails created by PHP using GD and/or ImageMagick</title>
<link rel="stylesheet" type="text/css" href="/style.css" title="style sheet">
</head>
<body bgcolor="#C5C5C5">
This is a demo of <a href="http://phpthumb.sourceforge.net"><b>phpThumb()</b></a> (current version: v<?php echo @$ServerInfo['phpthumb_version']; ?>)<br>
<br>
<b>Note:</b> this server is working on GD "<?php
echo $ServerInfo['gd_string'].'"';
if ($ServerInfo['gd_numeric'] >= 2) {
echo ', so images should be of optimal quality.';
} else {
echo ', so images (especially watermarks) do not look as good as they would on GD v2.';
}
?><br>
<hr size="1">
<a href="#showpic">phpThumb.demo.showpic.php demo here</a><br>
<a href="#gd1vs2">Difference between GD1 and GD2</a><br>
<hr size="1">
<table border="5" align="center" width="500" cellpadding="5"><tr><td>
<b>The following images have the textured background behind them to illustrate transparency effects.
Note that some browsers, notably Internet Explorer, are incapable of displaying alpha-channel PNGs.
See my page on the <a href="http://www.silisoftware.com/png_alpha_transparency/" target="_blank">PNG transparency problem</a>.
Other modern browsers such as <a href="http://www.mozilla.org">Mozilla/Firefox</a> display alpha-transparent PNGs with no problems.</b>
</td></tr></table><br>
<script language="Javascript" defer>
<!--
var agt = navigator.userAgent.toLowerCase();
if ((agt.indexOf("opera") == -1) && (navigator.product != "Gecko")) {
alert("You are (probably) using Internet Explorer and PNG transparency is (probably) broken");
}
// -->
</script>
<?php
$phpThumbBase = '../phpThumb.php?';
$img['background'] = 'images/lrock011.jpg';
$img['square'] = 'images/disk.jpg';
$img['landscape'] = 'images/loco.jpg';
$img['portrait'] = 'images/pineapple.jpg';
$img['unrotated'] = 'images/monkey.jpg';
$img['watermark'] = 'images/watermark.png';
$img['levels'] = 'images/bunnies.jpg';
$img['anigif'] = 'images/animaple.gif';
$img['alpha'] = 'images/alpha.png';
//$img['alpha'] = 'images/North15.gif';
$img['mask1'] = 'images/mask04.png';
$img['mask2'] = 'images/mask05.png';
$img['mask3'] = 'images/mask06.png';
$img['frame1'] = 'images/frame1.png';
$img['frame2'] = 'images/frame2.png';
$img['bmp'] = 'images/winnt.bmp';
$img['tiff'] = 'images/1024-none.tiff';
$img['wmf'] = 'images/computer.wmf';
$img['small'] = 'images/small.jpg';
$img['big'] = 'images/big.jpg';
$png_alpha = 'Note: PNG/ICO output is 32-bit with alpha transparency, subject to <a href="http://www.silisoftware.com/png_alpha_transparency/" target="_blank">PNG transparency problem</a> in Internet Explorer';
$only_gd = '<br>(only works with GD (any version), this server is '.($ServerInfo['gd_string'] ? 'running GD "<i>'.$ServerInfo['gd_string'].'</i>" so it <b><font color="green">will</font>' : 'not running any recognized version of GD so it <b><font color="red">will not</font>').'</b> work)';
$only_gd2 = '<br>(only works with GD v2.0+, this server is running GD "<i>'.($ServerInfo['gd_string'] ? $ServerInfo['gd_string'] : 'n/a').'</i>" so it <b>'.(($ServerInfo['gd_numeric'] >= 2) ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work)';
$only_php42 = '<br>(only works with PHP v4.2.0+, this server is running PHP v'.phpversion().' so it <b>'.(version_compare(phpversion(), '4.2.0', '>=') ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work)';
$only_php43 = '<br>(only works with PHP v4.3.0+, this server is running PHP v'.phpversion().' so it <b>'.(version_compare(phpversion(), '4.3.0', '>=') ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work)';
$only_php432 = '<br>(only works with PHP v4.3.2+, this server is running PHP v'.phpversion().' so it <b>'.(version_compare(phpversion(), '4.3.2', '>=') ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work (correctly))';
$only_php500 = '<br>(only works with PHP v5.0.0+, this server is running PHP v'.phpversion().' so it <b>'.(version_compare(phpversion(), '5.0.0', '>=') ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work (correctly))';
$php5_or_IM = '<br>(only works with PHP v5.0.0+ <i>or</i> ImageMagick, this server is running PHP v'.phpversion().' and "<i>'.($ServerInfo['im_version'] ? $ServerInfo['im_version'] : 'n/a').'</i>" so it <b>'.(($ServerInfo['im_version'] && version_compare(phpversion(), '5.0.0', '>=')) ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work (correctly))';
$only_exif = '<br>(only works when the EXIF extension is loaded, so on this server it <b>'.(extension_loaded('exif') ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work)';
$only_im = '<br>(requires ImageMagick, this server is running "<i>'.($ServerInfo['im_version'] ? $ServerInfo['im_version'] : 'n/a').'</i>" so it <b>'.($ServerInfo['im_version'] ? '<font color="green">will</font>' : '<font color="red">will not</font>').'</b> work)';
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['square'].'&w=200'), 'description' => 'width=200px');
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['square'].'&w=200&q=10'), 'description' => 'width=200px, JPEGquality=10%');
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['watermark'].'&w=400&aoe=1&bg=ffffff'), 'description' => 'width=400px, AllowOutputEnlargement enabled');
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['square'].'&w=250&sx=600&sy=5&sw=100&sh=100&aoe=1'), 'description' => 'section from (600x5 - 700x105) cropped and enlarged by 250%, AllowOutputEnlargement enabled');
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.urlencode('http://silisoftware.com/images/SiliSoft.gif').'&w=100'), 'description' => 'HTTP source image'.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['square'].'&w=200&fltr[]=wmi|'.$img['watermark'].'|BL'), 'description' => 'width=200px, watermark (bottom-left, 75% opacity)'.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['square'].'&w=200&fltr[]=wmi|'.$img['watermark'].'|*|25'), 'description' => 'width=200px, watermark (tiled, 25% opacity)'.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['watermark'].'&bg=00FFFF&f=png', $phpThumbBase.'src='.$img['watermark'].'&bg=00FFFF&f=gif', $phpThumbBase.'src='.$img['watermark'].'&bg=00FFFF&f=jpeg'), 'description' => 'source image (GIF) transpancy with transparent output (PNG, GIF) vs. specified background color (JPEG)');
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['anigif'], $phpThumbBase.'src='.$img['anigif'].'&w=25&f=gif', $phpThumbBase.'src='.$img['anigif'].'&w=25&f=png', $phpThumbBase.'src='.$img['anigif'].'&w=25&f=ico', $phpThumbBase.'src='.$img['anigif'].'&w=25&f=bmp', $phpThumbBase.'src='.$img['anigif'].'&w=25&f=jpeg'), 'description' => 'resize animated GIF. Notice how output format affects the result: GIF is animated and transparent; PNG and ICO are tranparent but not animated (first frame is rendered as a still image); JPEG and BMP are neither transparent nor animated. Any filters will disable animated resizing (may be fixed in a future version).<br>'.$only_im);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['alpha'].'&f=png', $phpThumbBase.'src='.$img['alpha'].'&f=ico', $phpThumbBase.'src='.$img['alpha'].'&f=gif', $phpThumbBase.'src='.$img['alpha'].'&f=jpeg'), 'description' => 'PNG alpha transparency test, using test image from the <a href="http://trific.ath.cx/web/png/">PNG transparency test page</a>'.$only_php432);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=usm|80|0.5|3'), 'description' => 'normal vs. unsharp masking at default settings'.$only_gd2);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=blur|1', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=blur|5'), 'description' => 'normal vs. blur at default (1) and heavy (5)'.$only_gd2);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=gblr', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=sblr'), 'description' => 'normal vs. gaussian blur vs. selective blur'.$only_php500.$only_gd2);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['portrait'].'&w=100&h=100&far=L&bg=0000FF&f=png&fltr[]=bord|1', $phpThumbBase.'src='.$img['landscape'].'&w=100&h=100&far=T&bg=FF0000&f=png&fltr[]=bord|1', $phpThumbBase.'src='.$img['portrait'].'&w=100&h=100&far=C&bg=0000FF&f=png&fltr[]=bord|1', $phpThumbBase.'src='.$img['landscape'].'&w=100&h=100&far=B&bg=FF0000&f=png&fltr[]=bord|1', $phpThumbBase.'src='.$img['portrait'].'&w=100&h=100&far=R&bg=0000FF&f=png&fltr[]=bord|1'), 'description' => 'Forced Aspect Ratio, colored background, PNG output'.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['portrait'].'&w=150&ar=L', $phpThumbBase.'src='.$img['landscape'].'&w=150&ar=L'), 'description' => 'auto-rotate counter-clockwise to landscape from portrait & lanscape'.$only_php42.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['portrait'].'&hp=100&wl=200', $phpThumbBase.'src='.$img['landscape'].'&hp=100&wl=200'), 'description' => 'auto-selection of W and H based on source image orientation');
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['unrotated'].'&w=150&h=150', $phpThumbBase.'src='.$img['unrotated'].'&w=150&h=150&ar=x'), 'description' => 'original image vs. auto-rotated based on EXIF data'.$only_php42.$only_exif.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&ra=30&bg=0000FF', $phpThumbBase.'src='.$img['landscape'].'&w=200&ra=30&f=png', $phpThumbBase.'src='.$img['alpha'].'&ra=30&f=png', $phpThumbBase.'src='.$img['alpha'].'&ra=30&f=gif'), 'description' => 'Rotated 30<33> (counter-clockwise), width=200px, blue background vs. transparent background vs. rotated image with pre-existing alpha'.$only_php42.$only_gd);
//$Examples[] = array('getstrings' => array($phpThumbBase.'src=images/1-bit.gif&ra=30&f=png', $phpThumbBase.'src=images/4-bit.gif&ra=30&f=png', $phpThumbBase.'src=images/8-bit.gif&ra=30&f=png'), 'description' => '2-color, 16-color, 256-color transparent GIFs'.$only_php42.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&h=300&far=1&bg=CCCCCC', $phpThumbBase.'src='.$img['landscape'].'&w=200&h=300&iar=1'), 'description' => 'Normal resize behavior (left) vs. Forced non-proportional resize (right)'.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=150&h=150&zc=1', $phpThumbBase.'src='.$img['portrait'].'&w=150&h=150&zc=1'), 'description' => 'Zoom-Crop');
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=bord|2|20|10|009900&f=png'), 'description' => '2px border, curved border corners (20px horizontal radius, 10px vertical radius)'.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=ric|50|20&f=png'), 'description' => 'curved border corners (20px vertical radius, 50px horizontal radius)<br>'.$png_alpha.$only_gd2.$only_php432);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=sat|75', $phpThumbBase.'src='.$img['landscape'].'&w=200', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=sat|-100'), 'description' => 'saturation -75% vs. normal vs. -100%'.$only_gd2);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=ds|75', $phpThumbBase.'src='.$img['landscape'].'&w=200', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=ds|-100'), 'description' => 'desaturated 75% vs. normal vs. -100%'.$only_gd2);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=clr|25|00FF00'), 'description' => 'colorized 25% to green (#00FF00)'.$only_gd2);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=gray', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=sep'), 'description' => 'grayscale vs. sepia'.$only_gd2);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=mask|'.$img['mask3'].'&f=png', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=mask|'.$img['mask1'].'&f=png', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=mask|'.$img['mask2'].'&f=jpeg&bg=9900CC&q=100'), 'description' => 'Assorted alpha masks (seen below) applied<br>'.$png_alpha.$only_php432.'<br>JPEG/GIF output is flattened to "bg" background color'.$only_gd2.'<br><img src="../'.$img['mask3'].'"> <img src="../'.$img['mask1'].'"> <img src="../'.$img['mask2'].'">');
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=drop|5|10|000000|225&f=png', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=mask|'.$img['mask3'].'&fltr[]=drop|5|10|000000|225&f=png', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=drop|5|10|000000|225&fltr[]=elip&f=png', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=elip&fltr[]=drop|5|10|000000|225&f=png'), 'description' => 'Drop shadow. Note how the order in which filters are applied matters.'.$only_php432.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=elip&f=png', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=elip&f=jpeg&bg=00FFFF'), 'description' => 'Elipse<br>'.$png_alpha.$only_php432.'<br>JPEG/GIF output is flattened to "bg" background color'.$only_gd2);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=flip|x', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=flip|y', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=flip|xy'), 'description' => 'flipped on X, Y and X+Y axes'.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=bvl|10|FFFFFF|000000', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=bvl|10|000000|FFFFFF'), 'description' => '10px bevel edge filter'.$only_php432.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=fram|3|2|CCCCCC|FFFFFF|000000', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=fram|3|2|CC9966|333333|CCCCCC'), 'description' => '3+2px frame filter'.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=neg'), 'description' => 'Negative filter (inverted color)'.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=th|105', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=mask|'.$img['mask1'].'&fltr[]=th|105&f=png'), 'description' => 'Threshold filter; showing preserved alpha channel'.$only_php432.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['portrait'].'&w=150', $phpThumbBase.'src='.$img['portrait'].'&w=150&fltr[]=rcd|16|1', $phpThumbBase.'src='.$img['portrait'].'&w=150&fltr[]=rcd|16|0', $phpThumbBase.'src='.$img['portrait'].'&w=150&fltr[]=gray&fltr[]=rcd|8|1'), 'description' => 'ReduceColorDepth filter; original vs. 16-color dither vs. 16-color nodither vs. 4-gray dither'.$only_gd2);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['levels'].'&w=200', $phpThumbBase.'src='.$img['levels'].'&w=200&fltr[]=lvl'), 'description' => 'original vs. Levels filter (default settings)'.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['portrait'].'&w=200', $phpThumbBase.'src='.$img['portrait'].'&w=200&fltr[]=wb', $phpThumbBase.'src='.$img['portrait'].'&w=200&fltr[]=wb&fltr[]=lvl'), 'description' => 'original vs. White Balance vs. White Balance + Levels'.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=300&fltr[]=hist|rgb', $phpThumbBase.'src='.$img['levels'].'&w=200&fltr[]=hist|*'), 'description' => 'histograms of RGB vs. grayscale'.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=300&fltr[]=edge'), 'description' => 'Edge Detect filter'.$php5_or_IM.$only_gd2);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=300&fltr[]=emb'), 'description' => 'Emboss filter'.$php5_or_IM.$only_gd2);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=300&fltr[]=mean'), 'description' => 'Mean Removal filter'.$only_php500.$only_gd2);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=300&fltr[]=smth'), 'description' => 'Smooth filter'.$only_php500.$only_gd2);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=gam|0.6', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=gam|1.6'), 'description' => 'Gamma corrected to 0.6 vs. 1.6'.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=brit|50', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=brit|-50'), 'description' => 'Brightness filter (original vs. +50 vs. -50)'.$only_gd2);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=cont|50', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=cont|-50'), 'description' => 'Contrast filter (original vs. +50 vs. -50)'.$only_gd2);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['portrait'].'&w=200&fltr[]=over|'.$img['frame1'].'|0', $phpThumbBase.'src='.$img['portrait'].'&w=200&fltr[]=over|'.$img['frame2'].'|1'), 'description' => 'Overlay vs. Underlay<br><br>Original over/under images:<br><table border="0"><tr><td style="padding: 20px; background-image: url(../'.$img['background'].');"><img src="../'.$img['frame1'].'"> <img src="../'.$img['frame2'].'"></td></tr></table>'.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=wmt|phpThumb|18|C|FF0000|loki.ttf|100|5|20&f=png', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=wmt|copyright+'.date('Y').'|3|BR|00FFFF||50&f=png', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=wmt|copyright+'.date('Y').'%0AphpThumb()|3|L|00FFFF&f=png'), 'description' => 'Text overlay, TTF and built-in fonts, multiple lines, metacharacters (height, width)'.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=wmt|thumbnail+=+^Xx^Y|3|BR|00FFFF||50&f=png', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=wmt|click%0Ahere%0A^FkkB|10|L|FF00FF|arial.ttf|100|0||333399|50|y&f=png', $phpThumbBase.'src='.$img['landscape'].'&w=200&fltr[]=wmt|resized:+^Xx^Y+to+^xx^y|10|B|FFFFFF|arial.ttf|100|0||000000|100|x&f=png'), 'description' => 'metacharacters (height, width), background color, background extend'.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'new=FF0000&w=100&h=50&fltr[]=bvl|10&fltr[]=wmt|hello|14|C|00FFFF|arial.ttf&f=png', $phpThumbBase.'new=FF0000|25&w=150&h=50&fltr[]=bvl|10&fltr[]=wmt|25%+opaque|14|C|0066FF|arial.ttf&f=png'), 'description' => 'Image created with "new", red background, bevel, TTF text'.$only_gd);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['bmp'].'&w=200'), 'description' => 'BMP source, width=200px');
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['tiff'], $phpThumbBase.'src='.$img['tiff'].'&w=200&aoe=1'), 'description' => 'TIFF source, width=200px'.$only_im);
$Examples[] = array('getstrings' => array($phpThumbBase.'src='.$img['wmf'].'&w=200'), 'description' => 'WMF source, width=200px'.$only_im);
//$Examples[] = array('getstrings' => array(''), 'description' => '');
foreach ($Examples as $key => $ExamplesArray) {
echo '<a href="#" name="'.$key.'" title="click to get URL link for example #'.$key.'" onClick="prompt(\'Here is the link to example #'.$key.'\', \'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'#'.$key.'\'); return false;">#'.$key.'</a>';
echo '<table border="0"><tr><td style="padding: 20px; background-image: url(../'.$img['background'].');">';
foreach ($ExamplesArray['getstrings'] as $dummy => $GETstring) {
echo '<a href="'.$GETstring.'&down='.urlencode($GETstring).'" title="'.htmlentities(str_replace($phpThumbBase, '', $GETstring), ENT_QUOTES).'">';
echo '<img border="0" src="'.$GETstring.'">';
echo '</a> ';
}
echo '</td></tr></table>';
echo '<xmp><img src="'.implode('">'."\n".'<img src="', $ExamplesArray['getstrings']).'"></xmp>';
echo $ExamplesArray['description'].'<br>';
echo '<br><br><hr size="1">';
}
echo '<a href="#" name="pathinfo" title="click to get URL link for PATH_INFO example" onClick="prompt(\'Here is the link to the PATH_INFO example\', \'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'#pathinfo\'); return false;">#pathinfo</a>';
echo '<table border="0"><tr><td style="padding: 20px; background-image: url(../'.$img['background'].');">';
echo '<img src="../phpThumb.php/fltr[]=sep;200x200;'.$img['portrait'].'">';
echo '</td></tr></table>';
echo '<xmp><img src="../phpThumb.php/fltr[]=sep;200x200;'.$img['portrait'].'"></xmp>';
echo 'PATH_INFO example<br>';
echo '<br><br><hr size="1">';
?>
<a name="gd1vs2"></a><br>
<table border="5" cellspacing="0" cellpadding="3" width="500">
<tr>
<td colspan="4">
<b>Illustration of potential difference between GD1.x and GD2.x</b><br>
In most cases the thumbnails produced by phpThumb() on GD v1.x are perfectly
acceptable, but in some cases it may look ugly. Diagonal lines and reducing a
very large source image increase chance for bad results (the house/sky picture
has both problems). Here are three static examples:
</td>
</tr>
<tr>
<td><b>GD v2.0.15</b></td>
<td><img src="../images/PHP-GD2-kayak.jpg" width="200" height="133" border="0" alt="kayak.jpg generated with phpThumb() on GD v2.0.15"></td>
<td><img src="../images/PHP-GD2-bottle.jpg" width="100" height="152" border="0" alt="bottle.jpg generated with phpThumb() on GD v2.0.15"></td>
<td><img src="../images/PHP-GD2-sky.jpg" width="200" height="150" border="0" alt="sky.jpg generated with phpThumb() on GD v2.0.15"></td>
</tr>
<tr>
<td><b>GD v1.6.2</b></td>
<td><img src="../images/PHP-GD1-kayak.jpg" width="200" height="133" border="0" alt="kayak.jpg generated with phpThumb() on GD v1.6.2"></td>
<td><img src="../images/PHP-GD1-bottle.jpg" width="100" height="152" border="0" alt="bottle.jpg generated with phpThumb() on GD v1.6.2"></td>
<td><img src="../images/PHP-GD1-sky.jpg" width="200" height="150" border="0" alt="sky.jpg generated with phpThumb() on GD v1.6.2"></td>
</tr>
</table><br>
<hr size="1">
<br>
<a name="showpic"></a>
<b>Demo of <i>phpThumb.demo.showpic.php</i></b><br>
<br>
Small picture (400x300), window opened at wrong size (640x480):<br>
<a href="javascript:void(0);" onClick="window.open('phpThumb.demo.showpic.php?src=../<?php echo $img['small']; ?>&title=This+is+a+small+picture', 'showpic1', 'width=640,height=480,resizable=no,status=no,menubar=no,toolbar=no,scrollbars=no');">
<img src="<?php echo $phpThumbBase.'src='.$img['small']; ?>&w=100" border="2"></a><br>
<br>
Big picture (2272x1704), window opened at wrong size (640x480):<br>
<a href="javascript:void(0);" onClick="window.open('phpThumb.demo.showpic.php?src=../<?php echo $img['big']; ?>&title=This+is+a+big+picture', 'showpic2', 'width=640,height=480,resizable=yes,status=no,menubar=no,toolbar=no,scrollbars=no');">
<img src="<?php echo $phpThumbBase.'src='.$img['big']; ?>&w=100" border="2"></a><br>
<br>
<hr size="1">
<?php
echo 'The source images, without manipulation:<ul>';
foreach ($img as $key => $value) {
echo '<li><a href="../'.$value.'">'.basename($value).'</a></li>';
}
echo '</ul><hr>';
?>
</body>
</html>

View File

@ -0,0 +1,72 @@
<?php
//////////////////////////////////////////////////////////////
/// phpThumb() by James Heinrich <info@silisoftware.com> //
// available at http://phpthumb.sourceforge.net ///
//////////////////////////////////////////////////////////////
/// //
// phpThumb.demo.object.php //
// James Heinrich <info@silisoftware.com> //
// //
// Example of how to use phpthumb.class.php as an object //
// //
//////////////////////////////////////////////////////////////
// Note: phpThumb.php is where the caching code is located, if
// you instantiate your own phpThumb() object that code is
// bypassed and it's up to you to handle the reading and
// writing of cached files.
require_once('../phpthumb.class.php');
// create 3 sizes of thumbnail
$thumbnail_widths = array(160, 320, 640);
foreach ($thumbnail_widths as $thumbnail_width) {
// Note: If you want to loop through and create multiple
// thumbnails from different image sources, you should
// create and dispose an instance of phpThumb() each time
// through the loop and not reuse the object.
$phpThumb = new phpThumb();
// set data
$phpThumb->setSourceFilename($_FILES['userfile']['tmp_name']);
// or $phpThumb->setSourceData($binary_image_data);
// or $phpThumb->setSourceImageResource($gd_image_resource);
// set parameters (see "URL Parameters" in phpthumb.readme.txt)
$phpThumb->w = $thumbnail_width;
//$phpThumb->h = 100;
//$phpThumb->fltr[] = 'gam|1.2';
// set options (see phpThumb.config.php)
// here you must preface each option with "config_"
$phpThumb->config_output_format = 'jpeg';
$phpThumb->config_imagemagick_path = '/usr/local/bin/convert';
//$phpThumb->config_allow_src_above_docroot = true; // needed if you're working outside DOCUMENT_ROOT, in a temp dir for example
// generate & output thumbnail
$output_filename = './thumbnails/'.basename($_FILES['userfile']['name']).'_'.$thumbnail_width.'.'.$phpThumb->config_output_format;
if ($phpThumb->GenerateThumbnail()) { // this line is VERY important, do not remove it!
if ($output_filename) {
if ($phpThumb->RenderToFile($output_filename)) {
// do something on success
echo 'Successfully rendered:<br><img src="'.$output_filename.'">';
} else {
// do something with debug/error messages
echo 'Failed (size='.$thumbnail_width.'):<pre>'.implode("\n\n", $phpThumb->debugmessages).'</pre>';
}
} else {
$phpThumb->OutputThumbnail();
}
} else {
// do something with debug/error messages
echo 'Failed (size='.$thumbnail_width.'):<pre>'.implode("\n\n", $phpThumb->debugmessages).'</pre>';
}
// remember to unset the object each time through the loop
unset($phpThumb);
}
?>

View File

@ -0,0 +1,95 @@
<?php
//////////////////////////////////////////////////////////////
/// phpThumb() by James Heinrich <info@silisoftware.com> //
// available at http://phpthumb.sourceforge.net ///
//////////////////////////////////////////////////////////////
/// //
// phpThumb.demo.random.php //
// James Heinrich <info@silisoftware.com> //
// //
// Display a random image from a specified directory. //
// Run with no parameters for usage instructions. //
// //
//////////////////////////////////////////////////////////////
function SelectRandomImage($dirname='.', $portrait=true, $landscape=true, $square=true) {
// return a random image filename from $dirname
// the last 3 parameters determine what aspect ratio of images
// may be returned
$possibleimages = array();
if ($dh = opendir($dirname)) {
while ($file = readdir($dh)) {
if (is_file($dirname.'/'.$file) && eregi('\.(jpg|jpeg|gif|png|tiff|bmp)$', $file)) {
if ($gis = @GetImageSize($dirname.'/'.$file)) {
if ($portrait && ($gis[0] < $gis[1])) {
// portrait
$possibleimages[] = $file;
} elseif ($landscape && ($gis[0] > $gis[1])) {
// landscape
$possibleimages[] = $file;
} elseif ($square) {
// square
$possibleimages[] = $file;
}
}
}
}
closedir($dh);
}
if (empty($possibleimages)) {
return false;
}
if (phpversion() < '4.2.0') {
mt_srand(time());
}
$randkey = mt_rand(0, count($possibleimages) - 1);
return realpath($dirname.'/'.$possibleimages[$randkey]);
}
if (@$_REQUEST['dir']) {
if (is_dir($_REQUEST['dir'])) {
if (!@$_REQUEST['o']) {
$_REQUEST['o'] = 'PLS';
}
$_REQUEST['o'] = strtoupper($_REQUEST['o']);
$portrait = (strpos(@$_REQUEST['o'], 'P') !== false);
$landscape = (strpos(@$_REQUEST['o'], 'L') !== false);
$square = (strpos(@$_REQUEST['o'], 'S') !== false);
$randomSRC = SelectRandomImage($_REQUEST['dir'], $portrait, $landscape, $square);
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
$randomSRC = str_replace('\\', '/', eregi_replace('^'.realpath(@$_SERVER['DOCUMENT_ROOT']), '', realpath($randomSRC)));
} else {
$randomSRC = str_replace(realpath(@$_SERVER['DOCUMENT_ROOT']), '', realpath($randomSRC));
}
$otherParams = array();
foreach ($_GET as $key => $value) {
if (($key == 'dir') || ($key == 'o')) {
continue;
}
if (is_array($value)) {
foreach ($value as $vkey => $vvalue) {
$otherParams[] = urlencode($key).'['.urlencode($vkey).']='.urlencode($vvalue);
}
} else {
$otherParams[] = urlencode($key).'='.urlencode($value);
}
}
header('Location: ../phpThumb.php?src='.urlencode($randomSRC).'&'.implode('&', $otherParams));
exit;
} else {
die($_REQUEST['dir'].' is not a directory');
}
} else {
echo '<html><body>Usage: <b>'.basename($_SERVER['PHP_SELF']).'?dir=<i>&lt;directory&gt;</i>&amp;<i>&lt;phpThumb parameters&gt;</i></b>&amp;o=<i>(P|L|S)</i><br><br>Examples:<ul>';
echo '<li>'.basename($_SERVER['PHP_SELF']).'?./images/&o=L <i>(landscape images only)</i></li>';
echo '<li>'.basename($_SERVER['PHP_SELF']).'?./images/&o=PS <i>(portrait or square images only)</i></li>';
echo '</ul></body></html>';
}
?>

View File

@ -0,0 +1,98 @@
<?php
//////////////////////////////////////////////////////////////
/// phpThumb() by James Heinrich <info@silisoftware.com> //
// available at http://phpthumb.sourceforge.net ///
//////////////////////////////////////////////////////////////
// //
// phpThumb.demo.showpic.php //
// James Heinrich <info@silisoftware.com> //
// 23 Feb 2004 //
// //
// This code is useful for popup pictures (e.g. thumbnails //
// you want to show larger, such as a larger version of a //
// product photo for example) but you don't know the image //
// dimensions before popping up. This script displays the //
// image with no window border, and resizes the window to //
// the size it needs to be (usually better to spawn it //
// large (600x400 for example) and let it auto-resize it //
// smaller), and if the image is larger than 90% of the //
// current screen area the window respawns itself with //
// scrollbars. //
// //
// Usage: //
// window.open('showpic.php?src=big.jpg&title=Big+picture', //
// 'popupwindowname', //
// 'width=600,height=400,menubar=no,toolbar=no') //
// //
// See demo linked from http://phpthumb.sourceforge.net ///
//////////////////////////////////////////////////////////////
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?php echo @$_GET['title']; ?></title>
<script language="Javascript">
<!--
// http://www.xs4all.nl/~ppk/js/winprop.html
function CrossBrowserResizeInnerWindowTo(newWidth, newHeight) {
if (self.innerWidth) {
frameWidth = self.innerWidth;
frameHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientWidth) {
frameWidth = document.documentElement.clientWidth;
frameHeight = document.documentElement.clientHeight;
} else if (document.body) {
frameWidth = document.body.clientWidth;
frameHeight = document.body.clientHeight;
} else {
return false;
}
if (document.layers) {
newWidth -= (parent.outerWidth - parent.innerWidth);
newHeight -= (parent.outerHeight - parent.innerHeight);
}
// original code
//parent.window.resizeTo(newWidth, newHeight);
// fixed code: James Heinrich, 20 Feb 2004
parent.window.resizeBy(newWidth - frameWidth, newHeight - frameHeight);
return true;
}
// -->
</script>
</head>
<body style="margin: 0px;">
<?php
if (get_magic_quotes_gpc()) {
$_GET['src'] = stripslashes($_GET['src']);
}
if ($imgdata = @getimagesize($_GET['src'])) {
// this would be an excellent place to put some caching stuff to avoid re-scanning every picture every time
// check for maximum dimensions to allow no-scrollbar window
echo '<script language="Javascript">'."\n";
echo 'if (((screen.width * 1.1) > '.$imgdata[0].') || ((screen.height * 1.1) > '.$imgdata[1].')) {'."\n";
// screen is large enough to fit whole picture on screen with 10% margin
echo 'document.writeln(\'<img src="'.$_GET['src'].'" border="0">\');';
echo 'CrossBrowserResizeInnerWindowTo('.$imgdata[0].', '.$imgdata[1].');'."\n";
echo '} else {'."\n";
// image is too large for screen: add scrollbars by putting the image inside an IFRAME
echo 'document.writeln(\'<iframe width="100%" height="100%" marginheight="0" marginwidth="0" frameborder="0" scrolling="on" src="'.$_GET['src'].'">Your browser does not support the IFRAME tag. Please use one that does (IE, Firefox, etc).<br><img src="'.$_GET['src'].'"></iframe>\');';
echo '}'."\n";
echo '</script>';
} else {
// cannot determine correct window size, or correct size too large: add scrollbars by putting the image inside an IFRAME
echo '<iframe width="100%" height="100%" marginheight="0" marginwidth="0" frameborder="0" scrolling="on" src="'.$_GET['src'].'"></iframe>';
}
?>
</body>
</html>

View File

@ -0,0 +1,41 @@
//////////////////////////////////////////////////////////////
/// phpThumb() by James Heinrich <info@silisoftware.com> //
// available at http://phpthumb.sourceforge.net ///
//////////////////////////////////////////////////////////////
/// //
// phpThumb() included and related demos //
// ///
//////////////////////////////////////////////////////////////
The phpThumb() distribution includes several demos, and it
should be self-evident what they do when you run them:
* phpThumb.demo.demo.php - shows a wide variety of samples,
basically all the different features and filters of phpThumb.
Note: sample image files are not included in the distribution
but can be downloaded from http://phpthumb.sourceforge.net/demo
* phpThumb.demo.check.php - configuration checker, will check
your config file and server configuration and warn of any
potential problems
* phpThumb.demo.object.php - example of how to call phpThumb
as an object.
* phpThumb.demo.random.php - select & display a random thumbnail
from a directory of images.
* phpThumb.demo.showpic.php - auto-resizes a popup window to
match the dimensions of the image it is displaying
Other people have created useful demos and/or extensions to
phpThumb(). Some of these I know of are:
* iManager - http://www.j-cons.com/news/
* iBrowser - http://www.j-cons.com/news/
* ThumbnailSelector - http://www.silisoftware.com/scripts/ThumbnailSelector
If you know of any others you think should be mentioned here
please let me know: info@silisoftware.com

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,203 @@
//////////////////////////////////////////////////////////////
/// phpThumb() by James Heinrich <info@silisoftware.com> //
// available at http://phpthumb.sourceforge.net ///
//////////////////////////////////////////////////////////////
/// //
// Frequently Asked Questions (FAQ) about phpThumb() //
// ///
//////////////////////////////////////////////////////////////
Q: My question isn't answered here and I can't find any
forums, how do I get support?
A: Please email me directly at info@silisoftware.com with
any questions, suggestions, donations, etc.
Q: What is the GPL? Can I use this for commercial sites?
A: See the GPL FAQ: http://www.gnu.org/licenses/gpl-faq.html
In general, if you just want to call phpThumb.php in the
standard <img src="phpThumb.php?src=pic.jpg&w=100"> manner
then there is no problem, you're free to do this no matter
if you site is commercial or not, or what license your code
is released under.
If you're calling phpThumb() as an object then you will
probably run into license issues, so consult the above FAQ
and the GPL itself.
No matter if you use phpThumb() commercially or not, no
payment is required. However, donations are always welcome
and can be made at http://phpthumb.sourceforge.net
Q: Some images generate thumbnails, but some fail (the original
non-resized image is output instead).
A: Your PHP installation does not have a high enough memory_limit
and ImageMagick is not installed on the server. The PHP memory
required is 5 times the number of pixels in the image.
For example:
640x480x5 = 1.5MB
1600x1200x5 = 9.2MB
You can adjust the PHP memory limit in php.ini (if you have
permission on your server to do so), or (better yet) install
ImageMagick on the server and that will bypass the memory limit
issue. If you can't do either of the above, you can resize the
images manually (with your favourite image editor) to a size
that your memory_limit setting can handle, and/or you can
re-save the images with an image editor that can embed an EXIF
thumbnail (Photoshop for example) which phpThumb can use as an
image source (lower image quality, but perhaps better than
nothing).
Q: I'm getting is this error message:
Failed: RenderToFile(<filename>) failed because
!is_resource($this->gdimg_output)
A: You missed the call to GenerateThumbnail() before
RenderToFile() or OutputThumbnail.
See /demo/phpThumb.demo.object.php for an example.
Q: I'm trying to save a phpThumb-generated image in Internet
Explorer and it saves in BMP format, why?
A: This is not phpThumb's fault, it is an IE issue:
http://support.microsoft.com/default.aspx?scid=kb;en-us;810978
http://support.microsoft.com/default.aspx?scid=kb;en-us;260650
Q: PNG images with transparent areas show up with gray background
in the areas that are supposed to be transparent.
A: Internet Explorer has had a broken PNG alpha-channel display
implementation for a decade, so it may never get fixed. Other
major browsers generally handle alpha-transparent PNGs fine.
See http://www.silisoftware.com/png_transparency/
For an alpha-channel PNG display in IE hack, see this page:
http://www.koivi.com/ie-png-transparency/
Q: I'm getting "<filename> does not exist" when I know the
file does exist
A: Check these two values are present and properly configured
in phpThumb.config.php (introduced in v1.6.0):
$PHPTHUMB_CONFIG['allow_src_above_docroot'] (default=false)
$PHPTHUMB_CONFIG['allow_src_above_phpthumb'] (default=true)
If your images are outside DOCUMENT_ROOT then you will have
to configure 'allow_src_above_docroot' to true.
Q: Should I use phpThumb.php, or use phpThumb() as an object?
A: phpThumb.php is easier to use (less coding) for basic uses.
phpThumb.php handles all caching; your own object will need
to have its own caching code. If you just want to display a
thumbnailed version of an existing image, use phpThumb.php
If you want to render one (or more) thumbnails to static
files (during upload, for example), that's an appropriate
use for the object mode. Also, phpThumb.config.php is only
used by phpThumb.php, so if you instantiate your own object
you need to manually set all configuration options because
phpThumb.config.php has NO effect. So, to repeat:
**always use phpThumb.php unless you NEED to have an object**
Q: Are there any front-end GUI interfaces to phpThumb()?
A: See /demo/readme.demo.txt
Q: Are there / have there been any security issues in phpThumb?
A: http://secunia.com/product/5199/
Q: Why can't Flash work with images output from phpThumb()?
A: Flash doesn't like progressive JPEG. Set:
$PHPTHUMB_CONFIG['output_interlace'] = false;
Q: Image quality is not very good - why?
A: If you're using GD v1.x, no way around it. Upgrade to GD v2.x
Q: Image quality is very bad, very pixelated -- why?
A: You may be trying to resize images larger than the available
PHP memory, so phpThumb is simply extracting and using the
EXIF thumbnail as the image source, which is usually about
160x120 (so if you resize it to 640x480 it will look very bad).
To calculate the required size for memory_limit in php.ini,
calculate the number of pixels in the image and multiply by 5:
For example, 1600x1200 = 1600 * 1200 * 5 = 9600000 = 10M
Q: Can I save the generated thumbnail to a file?
A: Yes, there are several ways to do so; the best way is to call
phpThumb as an object and call RenderToFile() to save the
thumbnail to whatever filename you want.
See /demo/phpThumb.demo.object.php for an example.
The other way is to use the 'file' parameter (see
/docs/phpthumb.readme.txt) but this parameter is deprecated
and may not exist in future versions of phpThumb().
Q: "Off-server thumbnailing is not allowed" -- how do I enable it?
A: By default, phpThumb() only makes thumbnails for the same domain
that it is running on. To allow it to make thumbnails for a limited
number of other domains, add them (in phpThumb.config.php) like this:
$PHPTHUMB_CONFIG['nohotlink_valid_domains'] = array(
@$_SERVER['HTTP_HOST'], 'example.com', 'www.example.com',
'subdomain.example.net', 'example.org');
To disable off-server thumbnail blocking, just set:
$PHPTHUMB_CONFIG['nohotlink_enabled'] = false;
Q: Is it possible to set the parameters (like w/h/fltr[]) in the config,
so that they can't be changed over the URL?
A: Take a look at $PHPTHUMB_DEFAULTS at the bottom of phpThumb.config.php
You'll want to set $PHPTHUMB_DEFAULTS_GETSTRINGOVERRIDE=false,
possibly also $PHPTHUMB_DEFAULTS_DISABLEGETPARAMS=true.
You may also want to investigate $PHPTHUMB_CONFIG['high_security_enabled']
(see the example at the bottom of phpThumb.config.php for how to call
images in HighSecurity mode.
Q: Is there a way to use phpThumb() object to create thumbnails without the
parameters in the URL showing the location of the image etc?
A: There is a demo in /demo/phpThumb.demo.object.php. You could modify this
into your own file, but there still remains the problem of passing
parameters to the file, whether it's phpThumb.php or your own instantiation
of a phpThumb() object. I would suggest is putting as many of the common
parameters into phpThumb.config.php as possible under $PHPTHUMB_DEFAULTS,
so you then don't have to pass them for each image. If you don't want people
modifying the parameters, turn on $PHPTHUMB_CONFIG['high_security_enabled']
and set a password (you'll need to generate the <img> tags with phpThumbURL()
provided at the bottom of phpThumb.config.php). If you don't want people
accessing your source images at all, you can place them outside DOCUMENT_ROOT
on your server (as long as phpThumb/PHP has read access to the directory).
The other option is to put your source images in a MySQL database and set
$PHPTHUMB_CONFIG['mysql_query'] and related parameters in phpThumb.config.php
to pull your source images from the database. That way it's impossible to
retrieve the images except through phpThumb.php, and if high_security is enabled,
then nobody can modify the parameters to view anything except what you want to show.
So, yes, it's possible to use your own object, but it's probably better to use
phpThumb.php if possible -- one notable issue is that phpThumb.php handles all
the caching, so you're on your own to deal with that if you create your own object.
Q: phpThumb runs slowly, as if the images aren't cached, when I use HTTP source
images (not on my server). How can I make it go faster?
A: $PHPTHUMB_CONFIG['cache_source_filemtime_ignore_remote'] = true;
// if true, remote source images will not be checked for modification date and
// cached image will be used if available, even if source image is changed or removed
Q: What does the "cache_default_only_suffix" configuration option do?
A: Cache files are normally created with big ugly names like
"phpThumb_cache_www.example.com_src1a482c2c760463795ff18faf073b389f_par3e099041c2f4a73041a7f5d7e7fc481a_dat1119952152.jpeg"
but if cache_default_only_suffix is enabled, cache filenames are simplified to
"pic_thumb.jpg" (for example). The problem is that only one version of that
thumbnail is possible, and you can never call it again with a different size,
or different filters, etc. Generally you don't want that enabled, but it's
there because some people asked for it.
Q: Why is the visual size of rotated images smaller than the unrotated images?
A: phpThumb fits the rotated image into the 'w' and 'h' dimensions.
Try not specifying a 'w' parameter: phpThumb.php?src=file.png&ra=15
That should leave the image the apparent same size as the unrotated image
(in actual fact the canvas size is enlarged to fit the rotated image in it).

View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

View File

@ -0,0 +1,527 @@
//////////////////////////////////////////////////////////////
/// phpThumb() by James Heinrich <info@silisoftware.com> //
// available at http://phpthumb.sourceforge.net ///
//////////////////////////////////////////////////////////////
/// //
// This code is released under the GNU GPL: //
// http://www.gnu.org/copyleft/gpl.html //
// //
// +-----------------------------------------------+ //
// | phpThumb() is free to use according to the | //
// | terms of the GPL. Donations also gratefully | //
// | GPL FAQ: http://gnu.org/licenses/gpl-faq.html | //
// | | //
// | Donations are gratefully accepted from happy | //
// | users :) See http://phpthumb.sourceforge.net | //
// | | //
// | If you like phpThumb(), please consider | //
// | writing a review at HotScripts.com: | //
// | http://www.hotscripts.com/Detailed/25654.html | //
// | | //
// | If you do use this code somewhere, send me | //
// | an email and tell me how/where you used it. | //
// +-----------------------------------------------+ //
// ///
//////////////////////////////////////////////////////////////
============
Description:
============
phpThumb() uses the GD library to create thumbnails from
images (GIF, PNG or JPEG) on the fly. The output size is
configurable (can be larger or smaller than the source),
and the source may be the entire image or only a portion
of the original image. True color and resampling is used
if GD v2.0+ is available, otherwise low-color and simple
resizing is used. Source image can be a physical file on
the server or can be retrieved from a database. GIFs are
supported on all versions of GD even if GD does not have
native GIF support thanks to the GIFutil class by Fabien
Ezber. AntiHotlinking feature prevents other people from
using your server to resize their thumbnails, or link to
your images from another server. The cache feature
reduces server load.
======
Usage:
======
Call phpThumb() just like you would a normal image.
Examples:
<IMG SRC="phpThumb.php?src=/image.jpg&w=100">
<IMG SRC="phpThumb.php?src=http://example.com/foo.jpg">
See the "demo" link on http://phpthumb.sourceforge.net
for more usage examples). Parameters that can be passed
are listed below under "URL Parameters".
NOTE: It's recommended you use the local image filename
wherever possible (rather than http://) because performance
is much better, less (or no) use of temp files, and the
last-modified check for cached files doesn't work for
remote files.
To access files over a LAN with Windows share names you
must use the network name (or IP) and not a mapped drive
name, for example:
//othercomputer/file.jpg - good
//192.168.2.1/file.jpg - good
z:/file.jpg - won't work
This is a PHP limitation (see www.php.net/file-exists)
Note: you may want to use "/" slashes instead of "\" if
you have magic_quotes_gpc enabled to avoid stripslashes
problems, although either slash should work if
magic_quotes_gpc is disabled
================================
Alternate PATH_INFO-style Usage:
================================
phpThumb.php can also be called by passing parameters not
after the usual "?" but like this:
phpThumb.php/<params>=<values>;<w>x<h>;<image>
For example:
phpThumb.php/100;pic.jpg
phpThumb.php/100;images/pic.jpg
phpThumb.php/100;/images/pic.jpg
phpThumb.php/100x200;pic.jpg
phpThumb.php/x200;pic.jpg
phpThumb.php/f=jpeg;q=50;100x200;pic.jpg
phpThumb.php/fltr[]=usm;100;pic.jpg
<image> must be the last item. Dimensions must be the second-
last item. As many key/value pairs for parameters can be
passed before those last two items, with each pair joined by
equals ("=") and seperated by semicolon (";")
==============
Configuration:
==============
There are some configuration options you may (but are
not required to) change. Most configuration options can
be set when you call phpThumb() - see list below), but
default configuration options (such as cache directory)
are in phpThumb.config.php - this is the only file you
should ever modify.
The configuration file is distributed as
phpThumb.config.php.default to prevent accidental
overwriting of old configuration settings. Please
migrate your old settings to the new file (if upgrading),
or delete your old config and rename the default to
phpThumb.config.php
The amount of memory required for phpThumb depends on
several factors: the dimensions of the source image,
the dimensions of the output image, whether unsharp
masking is applied, whether watermarks are applied, etc.
The auto-detection of memory limits works as a general
"safe" value. You may be able to exceed the auto value
by a small or large amount, depending on whether you
apply watermarks and/or sharpening, and the output size
of your thumbnails. I do not currently have a reliable
formula for calculating such things, but I will attempt
to craft one for future versions of phpThumb(). Until
then, set "max_source_pixels" in phpThumb.config.php to a
value that works well for you (or leave it alone if the
defaults give you no problems).
The configuration options you should maybe modify are:
* cache_directory - thumbnailing is slow and processor-
intensive. Enabling caching will dramatically speed
up future thumbnail serving
* max_source_pixels - This should be auto-detected, but
if auto-detection fails and you get an invalid image
from large source images, set this to about 20% of
your available PHP memory limit.
* imagemagick_path - If the source image is larger than
max_source_pixels allows, but ImageMagick is available
phpThumb() will use it to generate the thumbnail.
///////////////////////////////////////////////////////////
Note: High-Security mode is recommended enabled if possible.
Set $PHPTHUMB_CONFIG['high_security_enabled'] in
phpThumb.config.php to enable it. Each call to phpThumb
needs to be made through the function supplied at the
bottom of phpThumb.config.php which create the hash:
require_once('phpThumb.config.php');
echo '<img src="'.phpThumbURL('src=pic.jpg&w=50').'">';
///////////////////////////////////////////////////////////
==============================================
Calling as an object (not using phpThumb.php):
==============================================
NOTE: most people don't need to and should not do this.
If you just want to display resized images, please just
use phpThumb.php, not the object mode. To render output
to one (or more) files instead of the browser, you should
skip phpThumb.php and instantiate your own object. Please
take a look at /demo/phpThumb.demo.object.php for details.
Note: phpThumb.php is where the caching code is located, if
you instantiate your own phpThumb() object that code is
bypassed and it's up to you to handle the reading and
writing of cached files.
===============
URL Parameters:
===============
src = filename of source image
new = create new image, not thumbnail of existing image.
Requires "w" and "h" parameters set.
[ex: &new=FF0000|75] - red background, 75% opacity
Set to hex color string of background. Opacity is
optional (defaults to 100% opaque).
w = max width of output thumbnail in pixels
h = max height of output thumbnail in pixels
wp = max width for portrait images
hp = max height for portrait images
wl = max width for landscape images
hl = max height for landscape images
ws = max width for square images
hs = max height for square images
f = output image format ("jpeg", "png", or "gif")
q = JPEG compression (1=worst, 95=best, 75=default)
sx = left side of source rectangle (default = 0)
(values 0 < sx < 1 represent percentage)
sy = top side of source rectangle (default = 0)
(values 0 < sy < 1 represent percentage)
sw = width of source rectangle (default = fullwidth)
(values 0 < sw < 1 represent percentage)
sh = height of source rectangle (default = fullheight)
(values 0 < sh < 1 represent percentage)
zc = zoom-crop. Will auto-crop off the larger dimension
so that the image will fill the smaller dimension
(requires both "w" and "h"). Set "zc=1" to enable.
(overrides both "iar" and "far")
bg = background hex color (default = FFFFFF)
bc = border hex color (default = 000000)
fltr = filter system. Call as an array as follows:
- "brit" (Brightness) [ex: &fltr[]=brit|<value>]
where <value> is the amount +/- to adjust brightness
(range -255 to 255)
Availble in PHP5 with bundled GD only.
- "cont" (Constrast) [ex: &fltr[]=cont|<value>]
where <value> is the amount +/- to adjust contrast
(range -255 to 255)
Availble in PHP5 with bundled GD only.
- "gam" (Gamma Correction) [ex: &fltr[]=gam|<value>]
where <value> can be a number >0 to 10+ (default 1.0)
Must be >0 (zero gives no effect). There is no max,
although beyond 10 is pretty useless. Negative
numbers actually do something, maybe not quite the
desired effect, but interesting nonetheless.
- "sat" (SATuration) [ex: &fltr[]=sat|<value>]
where <value> is a number between zero (no change)
and -100 (complete desaturation = grayscale), or it
can be any positive number for increased saturation.
- "ds" (DeSaturate) [ex: &fltr[]=ds|<value>]
is an alias for "sat" except values are inverted
(positive values remove color, negative values boost
saturation)
- "gray" (Grayscale) [ex: &fltr[]=gray]
remove all color from image, make it grayscale
- "th" (Threshold) [ex: &fltr[]=th|<value>]
makes image greyscale, then sets all pixels brighter
than <value> (range 0-255) to white, and all pixels
darker than <value> to black
- "rcd" (Reduce Color Depth) [ex: &fltr[]=rcd|<c>|<d>]
where <c> is the number of colors (2-256) you want
in the output image, and <d> is "1" for dithering
(deault) or "0" for no dithering
- "clr" (Colorize) [ex: &fltr[]=clr|<value>|<color>]
where <value> is a number between 0 and 100 for the
amount of colorization, and <color> is the hex color
to colorize to.
- "sep" (Sepia) [ex: &fltr[]=sep|<value>|<color>]
where <value> is a number between 0 and 100 for the
amount of colorization (default=50), and <color> is
the hex color to colorize to (default=A28065).
Note: this behaves differently when applied by
ImageMagick, in which case 80 is default, and lower
values give brighter/yellower images and higher
values give darker/bluer images
- "usm" (UnSharpMask) [ex: &fltr[]=usm|<a>|<r>|<t>]
where <a> is the amount (default = 80), <r> is the
radius (default = 0.5), <t> is the threshold
(default = 3).
- "blur" (Blur) [ex: &fltr[]=blur|<radius>]
where (0 < <radius> < 25) (default = 1)
- "gblr" (Gaussian Blur) [ex: &fltr[]=gblr]
Availble in PHP5 with bundled GD only.
- "sblr" (Selective Blur) [ex: &fltr[]=gblr]
Availble in PHP5 with bundled GD only.
- "smth" (Smooth) [ex: &fltr[]=smth|<value>]
where <value> is the weighting value for the matrix
(range -10 to 10, default 6)
Availble in PHP5 with bundled GD only.
- "lvl" (Levels) [ex: &fltr[]=lvl|<channel>|<min>|<max>
where <channel> can be one of 'r', 'g', 'b', 'a' (for
Red, Green, Blue, Alpha respectively), or '*' for all
channels based on average grayscale value (default).
<min> and <max> are the clip points for the levels
and are set to clip 0.1% of each end by default.
(range = 0-255) and are set to clip 0.1% of each end
by default. Use -1 for min and/or max to invoke auto-
detect mode. Using default parameters (&fltr[]=lvl)
is similar to Auto Contrast in Adobe Photoshop.
- "wb" (White Balance) [ex: &fltr[]=wb|<c>]
where <c> is the target hex color to white balance
on, this color is what "should be" white, or light
gray. The filter attempts to maintain brightness so
any gray color can theoretically be used. If <c> is
omitted the filter guesses based on brightest pixels
in each of RGB
- "hist" (Histogram)
[ex: &fltr[]=hist|<b>|<c>|<w>|<h>|<a>|<o>|<m>]
Where <b> is the color band(s) to display, from back
to front (one or more of "rgba*" for Red Green Blue
Alpha and Grayscale respectively);
<c> is a semicolon-seperated list of hex colors to
use for each graph band (defaults to FF0000, 00FF00,
0000FF, 999999, FFFFFF respectively);
<w> and <h> are the width and height of the overlaid
histogram in pixels, or if <= 1 then percentage of
source image width/height;
<a> is the alignment (same as for "wmi" and "wmt");
<o> is opacity from 0 (transparent) to 100 (opaque)
(requires PHP v4.3.2, otherwise 100% opaque);
<m> is the edge (and inter-tile) margin in percent
- "over" (OVERlay/underlay image) overlays an image on
the thumbnail, or overlays the thumbnail on another
image (to create a picture frame for example)
[ex: &fltr[]=over|<i>|<u>|<m>|<o>]
where <i> is the image filename; <u> is "0" (default)
for overlay the image on top of the thumbnail or "1"
for overlay the thumbnail on top of the image; <m> is
the margin - can be absolute pixels, or if < 1 is a
percentage of the thumbnail size [must be < 0.5]
(default is 0 for overlay and 10% for underlay);
<o> is opacity (0 = transparent, 100 = opaque)
(requires PHP v4.3.2, otherwise 100% opaque);
(thanks raynerape<70>gmail*com, shabazz3<7A>msu*edu)
- "wmi" (WaterMarkImage)
[ex: &fltr[]=wmi|<f>|<a>|<o>|<m>] where
<f> is the filename of the image to overlay;
<a> is the alignment (one of BR, BL, TR, TL, C,
R, L, T, B, *) where B=bottom, T=top, L=left,
R=right, C=centre, *=tile);
<o> is opacity from 0 (transparent) to 100 (opaque)
(requires PHP v4.3.2, otherwise 100% opaque);
<m> is the edge (and inter-tile) margin in percent
- "wmt" (WaterMarkText)
[ex: &fltr[]=wmt|<t>|<s>|<a>|<c>|<f>|<o>|<m>|<n>|<b>|<O>|<x>]
where:
<t> is the text to use as a watermark;
Any instance of metacharacters will be replaced
with their calculated value. Currently supported:
^Fb = source image filesize in bytes
^Fk = source image filesize in kilobytes
^Fm = source image filesize in megabytes
^X = source image width in pixels
^Y = source image height in pixels
^x = thumbnail width in pixels
^y = thumbnail height in pixels
^^ = the character ^
<s> is the font size (1-5 for built-in font, or point
size for TrueType fonts);
<a> is the alignment (one of BR, BL, TR, TL, C, R, L,
T, B, * where B=bottom, T=top, L=left, R=right,
C=centre, *=tile);
<c> is the hex color of the text;
<f> is the filename of the TTF file (optional, if
omitted a built-in font will be used);
<o> is opacity from 0 (transparent) to 100 (opaque)
(requires PHP v4.3.2, otherwise 100% opaque);
<m> is the edge (and inter-tile) margin in percent;
<n> is the angle
<b> is the hex color of the background;
<O> is background opacity from 0 (transparent) to
100 (opaque)
(requires PHP v4.3.2, otherwise 100% opaque);
<x> is the direction(s) in which the background is
extended (either 'x' or 'y' (or both, but both
will obscure entire image))
Note: works with TTF fonts only, not built-in
(thanks mail<69>mmjaeger*com, craig<69>pc-fanatics*com)
- "flip" [ex: &fltr[]=flip|x or &fltr[]=flip|y]
flip image on X or Y axis
- "ric" [ex: &fltr[]=ric|<x>|<y>]
rounds off the corners of the image (to transparent
for PNG output), where <x> is the horizontal radius
of the curve and <y> is the vertical radius
- "elip" [ex: &fltr[]=elip]
similar to rounded corners but more extreme
- "mask" [ex: &fltr[]=mask|filename.png]
greyscale values of mask are applied as the alpha
channel to the main image. White is opaque, black
is transparent.
- "bvl" (BeVeL) [ex: &fltr[]=bvl|<w>|<c1>|<c2>]
where <w> is the bevel width, <c1> is the hex color
for the top and left shading, <c2> is the hex color
for the bottom and right shading
- "bord" (BORDer) [ex: &fltr[]=bord|<w>|<rx>|<ry>|<c>
where <w> is the width in pixels, <rx> and <ry> are
horizontal and vertical radii for rounded corners,
and <c> is the hex color of the border
- "fram" (FRAMe) draws a frame, similar to "bord" but
more configurable
[ex: &fltr[]=fram|<w1>|<w2>|<c1>|<c2>|<c3>]
where <w1> is the width of the main border, <w2> is
the width of each side of the bevel part, <c1> is the
hex color of the main border, <c2> is the highlight
bevel color, <c3> is the shadow bevel color
- "drop" (DROP shadow)
[ex: &fltr[]=drop|<d>|<w>|<clr>|<a>]
where <d> is distance from image to shadow, <w> is
width of shadow fade (not yet implemented), <clr> is
the hex color of the shadow, and <a> is the angle of
the shadow (default=225)
file = if set then thumbnail will be rendered to this
filename, not output and not cached.
(Deprecated. Disabled by default since v1.6.0.
You should instantiate your own object instead)
goto = URL to redirect to after rendering image to file
* Must begin with "http://"
* Requires file parameter set
(Deprecated. Disabled by default since v1.6.0.
You should instantiate your own object instead)
err = custom error image filename instead of showing
error messages (for use on production sites)
md5s = MD5 hash of the source image -- if this parameter is
passed with the hash of the source image then the
source image is not checked for existance or
modification and the cached file is used (if
available). If 'md5s' is passed an empty string then
phpThumb.php dies and outputs the correct MD5 hash
value. This parameter is the single-file equivalent
of 'cache_source_filemtime_ignore_*' configuration
paramters
xto = EXIF Thumbnail Only - set to only extract EXIF
thumbnail and not do any additional processing
ra = Rotate by Angle: angle of rotation in degrees
positive = counterclockwise, negative = clockwise
ar = Auto Rotate: set to "x" to use EXIF orientation
stored by camera. Can also be set to "l" or "L"
for landscape, or "p" or "P" for portrait. "l"
and "P" rotate the image clockwise, "L" and "p"
rotate the image counter-clockwise.
aoe = Output Allow Enlarging - override the setting for
$CONFIG['output_allow_enlarging'] (1=on, 0=off)
("far" and "iar" both override this and allow output
larger than input)
iar = Ignore Aspect Ratio - disable proportional resizing
and stretch image to fit "h" & "w" (which must both
be set). (1=on, 0=off) (overrides "far")
far = Force Aspect Ratio - image will be created at size
specified by "w" and "h" (which must both be set).
Alignment: L=left,R=right,T=top,B=bottom,C=center
BL,BR,TL,TR use the appropriate direction if the
image is landscape or portrait.
maxb = MAXimum Byte size - output quality is auto-set to
fit thumbnail into "maxb" bytes (compression
quality is adjusted for JPEG, bit depth is adjusted
for PNG and GIF)
down = filename to save image to. If this is set the
browser will prompt to save to this filename rather
than display the image
==============
General Notes:
==============
* Always use the local image filename wherever possible
rather than a full http:// URL because performance is
much better, less (or no) use of temp files, and the
last-modified check for cached files doesn't work for
remote files. For example:
good: phpThumb.php?src=/images/nicepic.jpg
bad: phpThumb.php?src=/home/httpd/example/images/nicepic.jpg
worse: phpThumb.php?src=http://example.com/images/nicepic.jpg
* Thumbnails will be scaled proportionately to fit in a
box of at most (width * height) pixels
(unless "iar" is set)
* Thumbnail caching for URL or database sources requires
an absolute directory name for $config_cache_directory
Physical file cached thumbnails will be recreated if
the source file changes, but remote/database files
cannot (modification time isn't readily available)
* If you need a GUI interface to phpThumb(), or for a user
to specify crop settings, or something like that please
see the list of known programs in /demo/readme.demos.txt
* Cropping images can be specified with either exact pixel
values for sx/sy/sw/sh parameters, or if those are set
to a value >0 and <1 then these are interpreted as a
percentage of the source image width/height. For example,
to crop 25% off all sides, you would specify parameters:
phpThumb.php?src=pic.jpg&sx=.25&sy=.25&sw=.5&sh=.5
* phpThumb() may have tempfile access issues on servers
where Safe Mode is enabled, specificly when accessing
a file over HTTP, or when a non-bundled version of GD
is in use. Specifying "config_temp_directory" may help
* Properly resolving /~user/ style filenames requires
apache_lookup_uri(), which is missing or broken in
Apache2, or if PHP is not installed as an Apache module.
phpThumb() does try and work around this if it is
unavailble, but you may have to specify a full filename
for "src" if you encounter problems.
* phpThumb() should work with PHP v4.0.6+, but seems to
have a few quirks before v4.1.0
EXIF thumbnail extraction requires PHP v4.2.0+
Image rotation requires PHP v4.3.0+. There have been
reports of problems with PHP older than v4.3.3
Some image filters require PHP v5.0.0+
Run /demo/phpThumb.demo.check.php to examine your server
* phpThumb() works better and faster when ImageMagick is
available. Most functions will work with only GD2, but
speed is much faster with ImageMagick, and much larger
images can be processed with ImageMagick than GD.
* phpThumb() works with GD v1.x, but works better with
GD v2.0+ because of the true-color image support
and ImageCopyResampled(). Also, there appears to be a
bug in ImageCopyResized() which is used with GD v1.x
where the bottom and/or right line of pixels is set
to the background color (due to a rounding error?)
NOTE: Please use the bundled version of GD if at all
possible (with PHP v4.3.0+) because the non-bundled
version has bugs which may cause PHP to crash:
* http://bugs.php.net/bug.php?id=21518
* http://bugs.php.net/bug.php?id=24174
phpThumb() has a workaround for the above bug but
there may be other bugs, and the workaround is slow.
Alpha transparent output requires GD >= 2.0.1 and
PHP >= 4.3.2
Most (if not all) filters require GD v2.x to function
at all. But many filters can be handled by ImageMagick
instead of GD.
* Filters handled by ImageMagick or GD:
- brit;cont;ds;sat;gray;clr;sep;gam;neg;th;rcd;flip;edge;
emb;lvl;blur;gblr;usm;
* Filters handled only by ImageMagick:
- none yet
* Filters handled only by GD + PHP5:
- sblr;mean;smth;
* Filters handled only by GD2:
- bvl;wmi;wmt;over;wb;hist;fram;drop;mask;elip;ric;bord;

View File

@ -0,0 +1,5 @@
This is the default location for TTF fonts.
You can safely delete or ignore this directory if you're not using
TTF fonts for text watermarks. You can also specify an alternate
directory in phpThumb.config.php

View File

@ -0,0 +1,3 @@
<?php
header('Location: demo/phpThumb.demo.demo1.php');
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

View File

@ -0,0 +1,241 @@
<?php
//////////////////////////////////////////////////////////////
/// phpThumb() by James Heinrich <info@silisoftware.com> //
// available at http://phpthumb.sourceforge.net ///
//////////////////////////////////////////////////////////////
/// //
// See: phpthumb.readme.txt for usage instructions //
// ///
//////////////////////////////////////////////////////////////
ob_start();
if (!file_exists(dirname(__FILE__).'/phpthumb.functions.php') || !include_once(dirname(__FILE__).'/phpthumb.functions.php')) {
ob_end_flush();
die('failed to include_once(phpthumb.functions.php) - realpath="'.realpath(dirname(__FILE__).'/phpthumb.functions.php').'"');
}
ob_end_clean();
// START USER CONFIGURATION SECTION:
// * DocumentRoot configuration
// phpThumb() depends on $_SERVER['DOCUMENT_ROOT'] to resolve path/filenames. This value is usually correct,
// but has been known to be broken on some servers. This value allows you to override the default value.
// Do not modify from the auto-detect default value unless you are having problems.
//$PHPTHUMB_CONFIG['document_root'] = '/home/httpd/httpdocs';
//$PHPTHUMB_CONFIG['document_root'] = 'c:\\webroot\\example.com\\www';
//$PHPTHUMB_CONFIG['document_root'] = $_SERVER['DOCUMENT_ROOT'];
//$PHPTHUMB_CONFIG['document_root'] = realpath((@$_SERVER['DOCUMENT_ROOT'] && file_exists(@$_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF'])) ? $_SERVER['DOCUMENT_ROOT'] : str_replace(dirname(@$_SERVER['PHP_SELF']), '', str_replace(DIRECTORY_SEPARATOR, '/', realpath('.'))));
$PHPTHUMB_CONFIG['document_root'] = realpath((getenv('DOCUMENT_ROOT') && ereg('^'.preg_quote(realpath(getenv('DOCUMENT_ROOT'))), realpath(__FILE__))) ? getenv('DOCUMENT_ROOT') : str_replace(dirname(@$_SERVER['PHP_SELF']), '', str_replace(DIRECTORY_SEPARATOR, '/', dirname(__FILE__))));
// * Cache directory configuration (choose only one of these - leave the other lines commented-out):
// Note: this directory must be writable (usually chmod 777 is neccesary) for caching to work.
// If the directory is not writable no error will be generated but caching will be disabled.
$PHPTHUMB_CONFIG['cache_directory'] = dirname(__FILE__).'/cache/'; // set the cache directory relative to the phpThumb() installation
//$PHPTHUMB_CONFIG['cache_directory'] = $PHPTHUMB_CONFIG['document_root'].'/phpthumb/cache/'; // set the cache directory to an absolute directory for all source images
//$PHPTHUMB_CONFIG['cache_directory'] = './cache/'; // set the cache directory relative to the source image - must start with '.' (will not work to cache URL- or database-sourced images, please use an absolute directory name)
//$PHPTHUMB_CONFIG['cache_directory'] = null; // disable thumbnail caching (not recommended)
$PHPTHUMB_CONFIG['cache_disable_warning'] = false; // If [cache_directory] is non-existant or not writable, and [cache_disable_warning] is false, an error image will be generated warning to either set the cache directory or disable the warning (to avoid people not knowing about the cache)
// * Cache culling: phpThumb can automatically limit the contents of the cache directory
// based on last-access date and/or number of files and/or total filesize.
//$PHPTHUMB_CONFIG['cache_maxage'] = null; // never delete cached thumbnails based on last-access time
$PHPTHUMB_CONFIG['cache_maxage'] = 86400 * 30; // delete cached thumbnails that haven't been accessed in more than [30 days] (value is maximum time since last access in seconds to avoid deletion)
//$PHPTHUMB_CONFIG['cache_maxsize'] = null; // never delete cached thumbnails based on byte size of cache directory
$PHPTHUMB_CONFIG['cache_maxsize'] = 10 * 1024 * 1024; // delete least-recently-accessed cached thumbnails when more than [10MB] of cached files are present (value is maximum bytesize of all cached files)
//$PHPTHUMB_CONFIG['cache_maxfiles'] = null; // never delete cached thumbnails based on number of cached files
$PHPTHUMB_CONFIG['cache_maxfiles'] = 200; // delete least-recently-accessed cached thumbnails when more than [500] cached files are present (value is maximum number of cached files to keep)
// * Source image cache configuration
$PHPTHUMB_CONFIG['cache_source_enabled'] = false; // if true, source images obtained via HTTP are cached to $PHPTHUMB_CONFIG['cache_source_directory']
$PHPTHUMB_CONFIG['cache_source_directory'] = dirname(__FILE__).'/cache/source/'; // set the cache directory for unprocessed source images
// * cache source modification date configuration
$PHPTHUMB_CONFIG['cache_source_filemtime_ignore_local'] = false; // if true, local source images will not be checked for modification date and cached image will be used if available, even if source image is changed or removed
$PHPTHUMB_CONFIG['cache_source_filemtime_ignore_remote'] = true; // if true, remote source images will not be checked for modification date and cached image will be used if available, even if source image is changed or removed. WARNING: cached performance MUCH slower if this is set to false.
// * Simplified cache filename configuration
// Instead of creating unique cache filenames for all parameter combinations, create "simple" cache files (eg: "pic_thumb.jpg")
// If cache_default_only_suffix is non-empty, GETstring parameters (except 'src') are ignored and only $PHPTHUMB_DEFAULTS
// parameters (set at the bottom of phpThumb.config.php) are used for processing.
// The '*' character MUST be used to represent the source image name
$PHPTHUMB_CONFIG['cache_default_only_suffix'] = ''; // cached in normal phpThumb manner
//$PHPTHUMB_CONFIG['cache_default_only_suffix'] = '*_thumb'; // cache 'pic.jpg' becomes 'pic_thumb.jpg' (or 'pic_thumb.png' if PNG output is selected, etc)
//$PHPTHUMB_CONFIG['cache_default_only_suffix'] = 'small-*'; // cache 'pic.jpg' becomes 'small-pic.jpg' (or 'small-pic.png' if PNG output is selected, etc)
$PHPTHUMB_CONFIG['cache_prefix'] = 'phpThumb_cache_'.str_replace('www.', '', @$_SERVER['SERVER_NAME']);
//$PHPTHUMB_CONFIG['cache_prefix'] = 'phpThumb_cache'; // allow phpThumb to share 1 set of cached files even if accessed under different servername/domains on same server
$PHPTHUMB_CONFIG['cache_force_passthru'] = true; // if true, cached image data will always be passed to browser; if false, HTTP redirect will be used instead
// * Temp directory configuration
// phpThumb() may need to create temp files. Usually the system temp dir is writable and can be used.
// Leave this value as NULL in most cases. If you get errors about "failed to open <filename> for writing"
// you should change this to a full pathname to a directory you do have write access to.
//$PHPTHUMB_CONFIG['temp_directory'] = '/tmp/';
$PHPTHUMB_CONFIG['temp_directory'] = null;
// maximum number of pixels in source image to attempt to process entire image.
// If this is zero then no limit on source image dimensions.
// If this is nonzero then this is the maximum number of pixels the source image
// can have to be processed normally, otherwise the embedded EXIF thumbnail will
// be used (if available) or an "image too large" notice will be displayed.
// This is to be used for large source images (> 1600x1200) and low PHP memory
// limits. If PHP runs out of memory the script will usually just die with no output.
// To calculate this number, multiply the dimensions of the largest image
// you can process with your memory limitation (e.g. 1600 * 1200 = 1920000)
// As a general guideline, this number will be about 20% of your PHP memory
// configuration, so 8M = 1,677,722; 16M = 3,355,443; 32M = 6,710,886; etc.
if (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.2', '>=') && !defined('memory_get_usage') && !@ini_get('memory_limit')) {
// memory_get_usage() will only be defined if your PHP is compiled with the --enable-memory-limit configuration option.
$PHPTHUMB_CONFIG['max_source_pixels'] = 0; // no memory limit
} else {
// calculate default max_source_pixels as 20% of memory limit configuration
$PHPTHUMB_CONFIG['max_source_pixels'] = round(max(intval(ini_get('memory_limit')), intval(get_cfg_var('memory_limit'))) * 1048576 * 0.20);
//$PHPTHUMB_CONFIG['max_source_pixels'] = 0; // no memory limit
//$PHPTHUMB_CONFIG['max_source_pixels'] = 1920000; // allow 1600x1200 images (2Mpx), no larger (about 10MB memory required)
//$PHPTHUMB_CONFIG['max_source_pixels'] = 3355443; // 16MB memory limit
//$PHPTHUMB_CONFIG['max_source_pixels'] = 3871488; // allow 2272x1704 images (4Mpx), no larger (about 16MB memory required)
}
// ImageMagick configuration
// If source image is larger than available memory limits as defined above in
// 'max_source_pixels' AND ImageMagick's "convert" program is available, phpThumb()
// will call ImageMagick to perform the thumbnailing of the source image to bypass
// the memory limitation. Leaving the value as NULL will cause phpThumb() to
// attempt to detect ImageMagick's presence with `which`
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
// Windows: set absolute pathname
$PHPTHUMB_CONFIG['imagemagick_path'] = 'C:/Program Files/ImageMagick-6.2.5-Q16/convert.exe';
} else {
// *nix: set absolute pathname to "convert", or leave as null if "convert" is in the path
//$PHPTHUMB_CONFIG['imagemagick_path'] = '/usr/local/bin/convert';
$PHPTHUMB_CONFIG['imagemagick_path'] = null;
}
// * Default output configuration:
$PHPTHUMB_CONFIG['output_format'] = 'jpeg'; // default output format ('jpeg', 'png' or 'gif') - thumbnail will be output in this format (if available in your version of GD). This is always overridden by ?f=___ GETstring parameter
$PHPTHUMB_CONFIG['output_maxwidth'] = 0; // default maximum thumbnail width. If this is zero then default width is the width of the source image. This is always overridden by ?w=___ GETstring parameter
$PHPTHUMB_CONFIG['output_maxheight'] = 0; // default maximum thumbnail height. If this is zero then default height is the height of the source image. This is always overridden by ?h=___ GETstring parameter
$PHPTHUMB_CONFIG['output_interlace'] = true; // if true: interlaced output for GIF/PNG, progressive output for JPEG; if false: non-interlaced for GIF/PNG, baseline for JPEG.
// * Error message configuration
$PHPTHUMB_CONFIG['error_image_width'] = 400; // default width for error images
$PHPTHUMB_CONFIG['error_image_height'] = 100; // default height for error images
$PHPTHUMB_CONFIG['error_message_image_default'] = ''; // Set this to the name of a generic error image (e.g. '/images/error.png') that you want displayed in place of any error message that may occur. This setting is overridden by the 'err' parameter, which does the same thing.
$PHPTHUMB_CONFIG['error_bgcolor'] = 'CCCCFF'; // background color of error message images
$PHPTHUMB_CONFIG['error_textcolor'] = 'FF0000'; // color of text in error messages
$PHPTHUMB_CONFIG['error_fontsize'] = 1; // size of text in error messages, from 1 (smallest) to 5 (largest)
$PHPTHUMB_CONFIG['error_die_on_error'] = true; // die with error message on any fatal error (recommended with standalone phpThumb.php)
$PHPTHUMB_CONFIG['error_silent_die_on_error'] = false; // simply die with no output of any kind on fatal errors (not recommended)
$PHPTHUMB_CONFIG['error_die_on_source_failure'] = true; // die with error message if source image cannot be processed by phpThumb() (usually because source image is corrupt in some way). If false the source image will be passed through unprocessed, if true (default) an error message will be displayed.
// * Off-server Thumbnailing Configuration:
$PHPTHUMB_CONFIG['nohotlink_enabled'] = true; // If false will allow thumbnailing from any source domain
$PHPTHUMB_CONFIG['nohotlink_valid_domains'] = array(@$_SERVER['HTTP_HOST']); // This is the list of domains for which thumbnails are allowed to be created. The default value of the current domain should be fine in most cases, but if neccesary you can add more domains in here, in the format 'www.example.com'
$PHPTHUMB_CONFIG['nohotlink_erase_image'] = true; // if true thumbnail is covered up with $PHPTHUMB_CONFIG['nohotlink_fill_color'] before text is applied, if false text is written over top of thumbnail
$PHPTHUMB_CONFIG['nohotlink_text_message'] = 'Off-server thumbnailing is not allowed'; // text of error message
// * Off-server Linking Configuration:
$PHPTHUMB_CONFIG['nooffsitelink_enabled'] = true; // If false will allow thumbnails to be linked to from any domain, if true only domains listed below in 'nooffsitelink_valid_domains' will be allowed.
$PHPTHUMB_CONFIG['nooffsitelink_valid_domains'] = array(@$_SERVER['HTTP_HOST']); // This is the list of domains for which thumbnails are allowed to be created. The default value of the current domain should be fine in most cases, but if neccesary you can add more domains in here, in the format 'www.example.com'
$PHPTHUMB_CONFIG['nooffsitelink_require_refer'] = false; // If false will allow standalone calls to phpThumb(). If true then only requests with a $_SERVER['HTTP_REFERER'] value in 'nooffsitelink_valid_domains' are allowed.
$PHPTHUMB_CONFIG['nooffsitelink_erase_image'] = true; // if true thumbnail is covered up with $PHPTHUMB_CONFIG['nohotlink_fill_color'] before text is applied, if false text is written over top of thumbnail
$PHPTHUMB_CONFIG['nooffsitelink_text_message'] = 'Image taken from '.@$_SERVER['HTTP_HOST']; // text of error message
// * Border & Background default colors
$PHPTHUMB_CONFIG['border_hexcolor'] = '000000'; // Default border color - usual HTML-style hex color notation (overidden with 'bc' parameter)
$PHPTHUMB_CONFIG['background_hexcolor'] = 'FFFFFF'; // Default background color when thumbnail aspect ratio does not match fixed-dimension box - usual HTML-style hex color notation (overridden with 'bg' parameter)
// * Watermark configuration
$PHPTHUMB_CONFIG['ttf_directory'] = dirname(__FILE__).'/fonts'; // Base directory for TTF font files
//$PHPTHUMB_CONFIG['ttf_directory'] = 'c:/windows/fonts';
// * MySQL configuration
// You may want to pull data from a database rather than a physical file
// If so, modify the $PHPTHUMB_CONFIG['mysql_query'] line to suit your database structure
// Note: the data retrieved must be the actual binary data of the image, not a URL or filename
// see http://www.billy-corgan.com/blog/archive/000143.php for a brief tutorial on this section
$PHPTHUMB_CONFIG['mysql_query'] = '';
//$PHPTHUMB_CONFIG['mysql_query'] = 'SELECT `picture` FROM `products` WHERE (`id` = \''.mysql_escape_string(@$_GET['id']).'\')';
// These 4 values must be modified if $PHPTHUMB_CONFIG['mysql_query'] is not empty, but may be ignored if $PHPTHUMB_CONFIG['mysql_query'] is blank.
$PHPTHUMB_CONFIG['mysql_hostname'] = 'localhost';
$PHPTHUMB_CONFIG['mysql_username'] = '';
$PHPTHUMB_CONFIG['mysql_password'] = '';
$PHPTHUMB_CONFIG['mysql_database'] = '';
// * Security configuration
$PHPTHUMB_CONFIG['high_security_enabled'] = false; // if enabled, requires 'high_security_password' set to at least 5 characters, and requires the use of phpThumbURL() function (at the bottom of phpThumb.config.php) to generate hashed URLs
$PHPTHUMB_CONFIG['high_security_password'] = ''; // required if 'high_security_enabled' is true, must be at least 5 characters long
$PHPTHUMB_CONFIG['disable_debug'] = false; // prevent phpThumb from displaying any information about your system. If true, phpThumbDebug and error messages will be disabled
$PHPTHUMB_CONFIG['allow_src_above_docroot'] = false; // if true, allow src to be anywhere in filesystem; if false (default) only allow src within document_root
$PHPTHUMB_CONFIG['allow_src_above_phpthumb'] = true; // if true (default), allow src to be anywhere in filesystem; if false only allow src within sub-directory of phpThumb installation
$PHPTHUMB_CONFIG['allow_parameter_file'] = false; // if true, allow use of 'file' parameter; if false (default) the 'file' parameter is disabled/ignored
$PHPTHUMB_CONFIG['allow_parameter_goto'] = false; // if true, allow use of 'goto' parameter; if false (default) the 'goto' parameter is disabled/ignored
// * HTTP UserAgent configuration
//$PHPTHUMB_CONFIG['http_user_agent'] = ''; // PHP default: none
//$PHPTHUMB_CONFIG['http_user_agent'] = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)'; // Windows XP, Internet Explorer
$PHPTHUMB_CONFIG['http_user_agent'] = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7'; // Windows XP, Firefox
// * Compatability settings
$PHPTHUMB_CONFIG['disable_pathinfo_parsing'] = false; // if true, $_SERVER[PATH_INFO] is not parsed. May be needed on some server configurations to allow normal behavior.
$PHPTHUMB_CONFIG['disable_imagecopyresampled'] = false; // if true, ImageCopyResampled is replaced with ImageCopyResampleBicubic. May be needed for buggy versions of PHP-GD.
$PHPTHUMB_CONFIG['disable_onlycreateable_passthru'] = true; // if true, any image that can be parsed by GetImageSize() can be passed through; if false, only images that can be converted to GD by ImageCreateFrom(JPEG|GIF|PNG) functions are allowed
// * Speed optimizations configuration
$PHPTHUMB_CONFIG['prefer_imagemagick'] = true; // If true, use ImageMagick to resize thumbnails if possible, since it is usually faster than GD functions; if false only use ImageMagick if PHP memory limit is too low.
$PHPTHUMB_CONFIG['use_exif_thumbnail_for_speed'] = false; // If true, and EXIF thumbnail is available, and is larger or equal to output image dimensions, use EXIF thumbnail rather than actual source image for generating thumbnail. Benefit is only speed, avoiding resizing large image.
// END USER CONFIGURATION SECTION
///////////////////////////////////////////////////////////////////////////////
// START DEFAULT PARAMETERS SECTION
// If any parameters are constant across ALL images, you can set them here
$PHPTHUMB_DEFAULTS_GETSTRINGOVERRIDE = true; // if true, any parameters in the URL will override the defaults set here; if false, any parameters set here cannot be overridden in the URL
$PHPTHUMB_DEFAULTS_DISABLEGETPARAMS = false; // if true, GETstring parameters will be ignored (except for 'src') and only below default parameters will be used; if false, both default and GETstring parameters will be used (depending on $PHPTHUMB_DEFAULTS_GETSTRINGOVERRIDE). Will be auto-set true if !empty($PHPTHUMB_CONFIG['cache_default_only_suffix'])
//$PHPTHUMB_DEFAULTS['w'] = 100;
//$PHPTHUMB_DEFAULTS['fltr'] = array('blur|10');
//$PHPTHUMB_DEFAULTS['q'] = 90;
// END DEFAULT PARAMETERS SECTION
///////////////////////////////////////////////////////////////////////////////
// Function for generating hashed calls to phpThumb if 'high_security_enabled'
// example:
// require_once('phpThumb.config.php');
// echo '<img src="'.phpThumbURL('src=pic.jpg&w=50').'">';
function phpThumbURL($ParameterString) {
global $PHPTHUMB_CONFIG;
return 'phpThumb.php?'.$ParameterString.'&hash='.md5($ParameterString.@$PHPTHUMB_CONFIG['high_security_password']);
}
///////////////////////////////////////////////////////////////////////////////
?>

View File

@ -0,0 +1,585 @@
<?php
//////////////////////////////////////////////////////////////
/// phpThumb() by James Heinrich <info@silisoftware.com> //
// available at http://phpthumb.sourceforge.net ///
//////////////////////////////////////////////////////////////
/// //
// See: phpthumb.changelog.txt for recent changes //
// See: phpthumb.readme.txt for usage instructions //
// ///
//////////////////////////////////////////////////////////////
error_reporting(E_ALL);
ini_set('display_errors', '1');
if (!@ini_get('safe_mode')) {
set_time_limit(60); // shouldn't take nearly this long in most cases, but with many filter and/or a slow server...
}
ini_set('magic_quotes_runtime', '0');
if (@ini_get('magic_quotes_runtime')) {
die('"magic_quotes_runtime" is set in php.ini, cannot run phpThumb with this enabled');
}
$starttime = array_sum(explode(' ', microtime()));
// this script relies on the superglobal arrays, fake it here for old PHP versions
if (phpversion() < '4.1.0') {
$_SERVER = $HTTP_SERVER_VARS;
$_GET = $HTTP_GET_VARS;
}
// instantiate a new phpThumb() object
ob_start();
if (!include_once(dirname(__FILE__).'/phpthumb.class.php')) {
ob_end_flush();
die('failed to include_once("'.realpath(dirname(__FILE__).'/phpthumb.class.php').'")');
}
ob_end_clean();
$phpThumb = new phpThumb();
$phpThumb->DebugTimingMessage('phpThumb.php start', __FILE__, __LINE__, $starttime);
// phpThumbDebug[0] used to be here, but may reveal too much
// info when high_security_mode should be enabled (not set yet)
if (file_exists(dirname(__FILE__).'/phpThumb.config.php')) {
ob_start();
if (include_once(dirname(__FILE__).'/phpThumb.config.php')) {
// great
} else {
ob_end_flush();
$phpThumb->ErrorImage('failed to include_once('.dirname(__FILE__).'/phpThumb.config.php) - realpath="'.realpath(dirname(__FILE__).'/phpThumb.config.php').'"');
}
ob_end_clean();
} elseif (file_exists(dirname(__FILE__).'/phpThumb.config.php.default')) {
$phpThumb->ErrorImage('Please rename "phpThumb.config.php.default" to "phpThumb.config.php"');
} else {
$phpThumb->ErrorImage('failed to include_once('.dirname(__FILE__).'/phpThumb.config.php) - realpath="'.realpath(dirname(__FILE__).'/phpThumb.config.php').'"');
}
if (!@$PHPTHUMB_CONFIG['disable_pathinfo_parsing'] && empty($_GET) && !empty($_SERVER['PATH_INFO'])) {
$_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', @$_SERVER['PHP_SELF']);
$args = explode(';', substr($_SERVER['PATH_INFO'], 1));
if (!empty($args)) {
$_GET['src'] = @$args[count($args) - 1];
}
if (eregi('^([0-9]*)x?([0-9]*)$', @$args[count($args) - 2], $matches)) {
$_GET['w'] = $matches[1];
$_GET['h'] = $matches[2];
}
for ($i = 0; $i < count($args) - 2; $i++) {
@list($key, $value) = explode('=', @$args[$i]);
if (substr($key, -2) == '[]') {
$_GET[substr($key, 0, -2)][] = $value;
} else {
$_GET[$key] = $value;
}
}
}
if (@$PHPTHUMB_CONFIG['high_security_enabled']) {
if (!@$_GET['hash']) {
$phpThumb->ErrorImage('ERROR: missing hash');
} elseif (strlen($PHPTHUMB_CONFIG['high_security_password']) < 5) {
$phpThumb->ErrorImage('ERROR: strlen($PHPTHUMB_CONFIG[high_security_password]) < 5');
} elseif ($_GET['hash'] != md5(str_replace('&hash='.$_GET['hash'], '', $_SERVER['QUERY_STRING']).$PHPTHUMB_CONFIG['high_security_password'])) {
$phpThumb->ErrorImage('ERROR: invalid hash');
}
}
////////////////////////////////////////////////////////////////
// Debug output, to try and help me diagnose problems
$phpThumb->DebugTimingMessage('phpThumbDebug[0]', __FILE__, __LINE__);
if (@$_GET['phpThumbDebug'] == '0') {
$phpThumb->phpThumbDebug();
}
////////////////////////////////////////////////////////////////
// returned the fixed string if the evil "magic_quotes_gpc" setting is on
if (get_magic_quotes_gpc()) {
$RequestVarsToStripSlashes = array('src', 'wmf', 'file', 'err', 'goto', 'down');
foreach ($RequestVarsToStripSlashes as $dummy => $key) {
if (isset($_GET[$key])) {
$_GET[$key] = stripslashes($_GET[$key]);
}
}
}
if (!@$_SERVER['PATH_INFO'] && !@$_SERVER['QUERY_STRING']) {
echo 'phpThumb() v'.$phpThumb->phpthumb_version.'<br><a href="http://phpthumb.sourceforge.net">http://phpthumb.sourceforge.net</a><br><br>ERROR: no parameters specified';
unset($phpThumb);
exit;
}
if (@$_GET['src'] && isset($_GET['md5s']) && empty($_GET['md5s'])) {
if (eregi('^(f|ht)tps?://', $_GET['src'])) {
if ($rawImageData = phpthumb_functions::SafeURLread($_GET['src'], $error)) {
$md5s = md5($rawImageData);
}
} else {
$SourceFilename = $phpThumb->ResolveFilenameToAbsolute($_GET['src']);
if (is_readable($SourceFilename)) {
$md5s = phpthumb_functions::md5_file_safe($SourceFilename);
} else {
$phpThumb->ErrorImage('ERROR: "'.$SourceFilename.'" cannot be read');
}
}
if (@$_SERVER['HTTP_REFERER']) {
$phpThumb->ErrorImage('&md5s='.$md5s);
} else {
die('&md5s='.$md5s);
}
}
if (!empty($PHPTHUMB_CONFIG)) {
foreach ($PHPTHUMB_CONFIG as $key => $value) {
$keyname = 'config_'.$key;
$phpThumb->setParameter($keyname, $value);
if (!eregi('password', $key)) {
$phpThumb->DebugMessage('setParameter('.$keyname.', '.$phpThumb->phpThumbDebugVarDump($value).')', __FILE__, __LINE__);
}
}
} else {
$phpThumb->DebugMessage('$PHPTHUMB_CONFIG is empty', __FILE__, __LINE__);
}
////////////////////////////////////////////////////////////////
// Debug output, to try and help me diagnose problems
$phpThumb->DebugTimingMessage('phpThumbDebug[1]', __FILE__, __LINE__);
if (@$_GET['phpThumbDebug'] == '1') {
$phpThumb->phpThumbDebug();
}
////////////////////////////////////////////////////////////////
$parsed_url_referer = parse_url(@$_SERVER['HTTP_REFERER']);
if ($phpThumb->config_nooffsitelink_require_refer && !in_array(@$parsed_url_referer['host'], $phpThumb->config_nohotlink_valid_domains)) {
$phpThumb->ErrorImage('config_nooffsitelink_require_refer enabled and '.(@$parsed_url_referer['host'] ? '"'.$parsed_url_referer['host'].'" is not an allowed referer' : 'no HTTP_REFERER exists'));
}
$parsed_url_src = parse_url(@$_GET['src']);
if ($phpThumb->config_nohotlink_enabled && $phpThumb->config_nohotlink_erase_image && eregi('^(f|ht)tps?://', @$_GET['src']) && !in_array(@$parsed_url_src['host'], $phpThumb->config_nohotlink_valid_domains)) {
$phpThumb->ErrorImage($phpThumb->config_nohotlink_text_message);
}
if ($phpThumb->config_mysql_query) {
if ($cid = @mysql_connect($phpThumb->config_mysql_hostname, $phpThumb->config_mysql_username, $phpThumb->config_mysql_password)) {
if (@mysql_select_db($phpThumb->config_mysql_database, $cid)) {
if ($result = @mysql_query($phpThumb->config_mysql_query, $cid)) {
if ($row = @mysql_fetch_array($result)) {
mysql_free_result($result);
mysql_close($cid);
$phpThumb->setSourceData($row[0]);
unset($row);
} else {
mysql_free_result($result);
mysql_close($cid);
$phpThumb->ErrorImage('no matching data in database.');
}
} else {
mysql_close($cid);
$phpThumb->ErrorImage('Error in MySQL query: "'.mysql_error($cid).'"');
}
} else {
mysql_close($cid);
$phpThumb->ErrorImage('cannot select MySQL database: "'.mysql_error($cid).'"');
}
} else {
$phpThumb->ErrorImage('cannot connect to MySQL server');
}
unset($_GET['id']);
}
////////////////////////////////////////////////////////////////
// Debug output, to try and help me diagnose problems
$phpThumb->DebugTimingMessage('phpThumbDebug[2]', __FILE__, __LINE__);
if (@$_GET['phpThumbDebug'] == '2') {
$phpThumb->phpThumbDebug();
}
////////////////////////////////////////////////////////////////
if (@$PHPTHUMB_CONFIG['cache_default_only_suffix'] && (strpos($PHPTHUMB_CONFIG['cache_default_only_suffix'], '*') !== false)) {
$PHPTHUMB_DEFAULTS_DISABLEGETPARAMS = true;
}
$allowedGETparameters = array('src', 'new', 'w', 'h', 'wp', 'hp', 'wl', 'hl', 'ws', 'hs', 'f', 'q', 'sx', 'sy', 'sw', 'sh', 'zc', 'bc', 'bg', 'bgt', 'fltr', 'file', 'goto', 'err', 'xto', 'ra', 'ar', 'aoe', 'far', 'iar', 'maxb', 'down', 'phpThumbDebug', 'hash', 'md5s');
foreach ($_GET as $key => $value) {
if (@$PHPTHUMB_DEFAULTS_DISABLEGETPARAMS && ($key != 'src')) {
// disabled, do not set parameter
$phpThumb->DebugMessage('ignoring $_GET['.$key.'] because of $PHPTHUMB_DEFAULTS_DISABLEGETPARAMS', __FILE__, __LINE__);
} elseif (in_array($key, $allowedGETparameters)) {
$phpThumb->DebugMessage('setParameter('.$key.', '.$phpThumb->phpThumbDebugVarDump($value).')', __FILE__, __LINE__);
$phpThumb->setParameter($key, $value);
} else {
$phpThumb->ErrorImage('Forbidden parameter: '.$key);
}
}
if (!empty($PHPTHUMB_DEFAULTS) && is_array($PHPTHUMB_DEFAULTS)) {
$phpThumb->DebugMessage('setting $PHPTHUMB_DEFAULTS['.implode(';', array_keys($PHPTHUMB_DEFAULTS)).']', __FILE__, __LINE__);
foreach ($PHPTHUMB_DEFAULTS as $key => $value) {
if ($PHPTHUMB_DEFAULTS_GETSTRINGOVERRIDE || !isset($_GET[$key])) {
$phpThumb->DebugMessage('setParameter('.$key.', '.$phpThumb->phpThumbDebugVarDump($value).')', __FILE__, __LINE__);
$phpThumb->setParameter($key, $value);
}
}
}
////////////////////////////////////////////////////////////////
// Debug output, to try and help me diagnose problems
$phpThumb->DebugTimingMessage('phpThumbDebug[3]', __FILE__, __LINE__);
if (@$_GET['phpThumbDebug'] == '3') {
$phpThumb->phpThumbDebug();
}
////////////////////////////////////////////////////////////////
//if (!@$_GET['phpThumbDebug'] && !$phpThumb->sourceFilename && !function_exists('ImageJPEG') && !function_exists('ImagePNG') && !function_exists('ImageGIF')) {
if (!@$_GET['phpThumbDebug'] && !is_file($phpThumb->sourceFilename) && !phpthumb_functions::gd_version()) {
if (!headers_sent()) {
// base64-encoded error image in GIF format
$ERROR_NOGD = 'R0lGODlhIAAgALMAAAAAABQUFCQkJDY2NkZGRldXV2ZmZnJycoaGhpSUlKWlpbe3t8XFxdXV1eTk5P7+/iwAAAAAIAAgAAAE/vDJSau9WILtTAACUinDNijZtAHfCojS4W5H+qxD8xibIDE9h0OwWaRWDIljJSkUJYsN4bihMB8th3IToAKs1VtYM75cyV8sZ8vygtOE5yMKmGbO4jRdICQCjHdlZzwzNW4qZSQmKDaNjhUMBX4BBAlmMywFSRWEmAI6b5gAlhNxokGhooAIK5o/pi9vEw4Lfj4OLTAUpj6IabMtCwlSFw0DCKBoFqwAB04AjI54PyZ+yY3TD0ss2YcVmN/gvpcu4TOyFivWqYJlbAHPpOntvxNAACcmGHjZzAZqzSzcq5fNjxFmAFw9iFRunD1epU6tsIPmFCAJnWYE0FURk7wJDA0MTKpEzoWAAskiAAA7';
header('Content-Type: image/gif');
echo base64_decode($ERROR_NOGD);
} else {
echo '*** ERROR: No PHP-GD support available ***';
}
exit;
}
// check to see if file can be output from source with no processing or caching
$CanPassThroughDirectly = true;
if ($phpThumb->rawImageData) {
// data from SQL, should be fine
} elseif (eregi('^(f|ht)tp\://', $phpThumb->src)) {
$phpThumb->DebugMessage('$CanPassThroughDirectly=false because eregi("^(f|ht)tp\://", '.$phpThumb->src.')', __FILE__, __LINE__);
$CanPassThroughDirectly = false;
} elseif (!@is_file($phpThumb->sourceFilename)) {
$phpThumb->DebugMessage('$CanPassThroughDirectly=false because !@is_file('.$phpThumb->sourceFilename.')', __FILE__, __LINE__);
$CanPassThroughDirectly = false;
} elseif (!@is_readable($phpThumb->sourceFilename)) {
$phpThumb->DebugMessage('$CanPassThroughDirectly=false because !@is_readable('.$phpThumb->sourceFilename.')', __FILE__, __LINE__);
$CanPassThroughDirectly = false;
}
foreach ($_GET as $key => $value) {
switch ($key) {
case 'src':
// allowed
break;
case 'w':
case 'h':
// might be OK if exactly matches original
break;
case 'phpThumbDebug':
// handled in direct-passthru code
break;
default:
// all other parameters will cause some processing,
// therefore cannot pass through original image unmodified
$CanPassThroughDirectly = false;
$UnAllowedGET[] = $key;
break;
}
}
if (!empty($UnAllowedGET)) {
$phpThumb->DebugMessage('$CanPassThroughDirectly=false because $_GET['.implode(';', array_unique($UnAllowedGET)).'] are set', __FILE__, __LINE__);
}
////////////////////////////////////////////////////////////////
// Debug output, to try and help me diagnose problems
$phpThumb->DebugTimingMessage('phpThumbDebug[4]', __FILE__, __LINE__);
if (@$_GET['phpThumbDebug'] == '4') {
$phpThumb->phpThumbDebug();
}
////////////////////////////////////////////////////////////////
function SendSaveAsFileHeaderIfNeeded() {
if (headers_sent()) {
return false;
}
global $phpThumb;
if (@$_GET['down']) {
$downloadfilename = ereg_replace('[/\\:\*\?"<>|]', '_', $_GET['down']);
if (phpthumb_functions::version_compare_replacement(phpversion(), '4.1.0', '>=')) {
$downloadfilename = trim($downloadfilename, '.');
}
if (@$downloadfilename) {
$phpThumb->DebugMessage('SendSaveAsFileHeaderIfNeeded() sending header: Content-Disposition: attachment; filename="'.$downloadfilename.'"', __FILE__, __LINE__);
header('Content-Disposition: attachment; filename="'.$downloadfilename.'"');
return true;
}
}
$phpThumb->DebugMessage('SendSaveAsFileHeaderIfNeeded() sending header: Content-Disposition: inline', __FILE__, __LINE__);
header('Content-Disposition: inline');
return true;
}
$phpThumb->DebugMessage('$CanPassThroughDirectly="'.intval($CanPassThroughDirectly).'" && $phpThumb->src="'.$phpThumb->src.'"', __FILE__, __LINE__);
while ($CanPassThroughDirectly && $phpThumb->src) {
// no parameters set, passthru
$SourceFilename = $phpThumb->ResolveFilenameToAbsolute($phpThumb->src);
// security and size checks
if ($phpThumb->getimagesizeinfo = @GetImageSize($SourceFilename)) {
$phpThumb->DebugMessage('Direct passthru GetImageSize() returned [w='.$phpThumb->getimagesizeinfo[0].';h='.$phpThumb->getimagesizeinfo[1].';t='.$phpThumb->getimagesizeinfo[2].']', __FILE__, __LINE__);
if (!@$_REQUEST['w'] && !@$_REQUEST['wp'] && !@$_REQUEST['wl'] && !@$_REQUEST['ws'] && !@$_REQUEST['h'] && !@$_REQUEST['hp'] && !@$_REQUEST['hl'] && !@$_REQUEST['hs']) {
// no resizing needed
$phpThumb->DebugMessage('Passing "'.$SourceFilename.'" through directly, no resizing required ("'.$phpThumb->getimagesizeinfo[0].'"x"'.$phpThumb->getimagesizeinfo[1].'")', __FILE__, __LINE__);
} elseif (($phpThumb->getimagesizeinfo[0] <= @$_REQUEST['w']) && ($phpThumb->getimagesizeinfo[1] <= @$_REQUEST['h']) && ((@$_REQUEST['w'] == $phpThumb->getimagesizeinfo[0]) || (@$_REQUEST['h'] == $phpThumb->getimagesizeinfo[1]))) {
// image fits into 'w'x'h' box, and at least one dimension matches exactly, therefore no resizing needed
$phpThumb->DebugMessage('Passing "'.$SourceFilename.'" through directly, no resizing required ("'.$phpThumb->getimagesizeinfo[0].'"x"'.$phpThumb->getimagesizeinfo[1].'" fits inside "'.@$_REQUEST['w'].'"x"'.@$_REQUEST['h'].'")', __FILE__, __LINE__);
} else {
$phpThumb->DebugMessage('Not passing "'.$SourceFilename.'" through directly because resizing required (from "'.$phpThumb->getimagesizeinfo[0].'"x"'.$phpThumb->getimagesizeinfo[1].'" to "'.@$_REQUEST['w'].'"x"'.@$_REQUEST['h'].'")', __FILE__, __LINE__);
break;
}
switch ($phpThumb->getimagesizeinfo[2]) {
case 1: // GIF
case 2: // JPG
case 3: // PNG
// great, let it through
break;
default:
// browser probably can't handle format, remangle it to JPEG/PNG/GIF
$phpThumb->DebugMessage('Not passing "'.$SourceFilename.'" through directly because $phpThumb->getimagesizeinfo[2] = "'.$phpThumb->getimagesizeinfo[2].'"', __FILE__, __LINE__);
break 2;
}
$ImageCreateFunctions = array(1=>'ImageCreateFromGIF', 2=>'ImageCreateFromJPEG', 3=>'ImageCreateFromPNG');
$theImageCreateFunction = @$ImageCreateFunctions[$phpThumb->getimagesizeinfo[2]];
if ($phpThumb->config_disable_onlycreateable_passthru || (function_exists($theImageCreateFunction) && ($dummyImage = @$theImageCreateFunction($SourceFilename)))) {
// great
if (@is_resource($dummyImage)) {
unset($dummyImage);
}
if (headers_sent()) {
$phpThumb->ErrorImage('Headers already sent ('.basename(__FILE__).' line '.__LINE__.')');
exit;
}
if (@$_GET['phpThumbDebug']) {
$phpThumb->DebugTimingMessage('skipped direct $SourceFilename passthru', __FILE__, __LINE__);
$phpThumb->DebugMessage('Would have passed "'.$SourceFilename.'" through directly, but skipping due to phpThumbDebug', __FILE__, __LINE__);
break;
}
SendSaveAsFileHeaderIfNeeded();
header('Last-Modified: '.gmdate('D, d M Y H:i:s', @filemtime($SourceFilename)).' GMT');
if ($contentType = phpthumb_functions::ImageTypeToMIMEtype(@$phpThumb->getimagesizeinfo[2])) {
header('Content-Type: '.$contentType);
}
@readfile($SourceFilename);
exit;
} else {
$phpThumb->DebugMessage('Not passing "'.$SourceFilename.'" through directly because ($phpThumb->config_disable_onlycreateable_passthru = "'.$phpThumb->config_disable_onlycreateable_passthru.'") and '.$theImageCreateFunction.'() failed', __FILE__, __LINE__);
break;
}
} else {
$phpThumb->DebugMessage('Not passing "'.$SourceFilename.'" through directly because GetImageSize() failed', __FILE__, __LINE__);
break;
}
break;
}
////////////////////////////////////////////////////////////////
// Debug output, to try and help me diagnose problems
$phpThumb->DebugTimingMessage('phpThumbDebug[5]', __FILE__, __LINE__);
if (@$_GET['phpThumbDebug'] == '5') {
$phpThumb->phpThumbDebug();
}
////////////////////////////////////////////////////////////////
function RedirectToCachedFile() {
global $phpThumb, $PHPTHUMB_CONFIG;
$nice_cachefile = str_replace(DIRECTORY_SEPARATOR, '/', $phpThumb->cache_filename);
$nice_docroot = str_replace(DIRECTORY_SEPARATOR, '/', rtrim($PHPTHUMB_CONFIG['document_root'], '/\\'));
$parsed_url = @parse_url(@$_SERVER['HTTP_REFERER']);
$nModified = filemtime($phpThumb->cache_filename);
if ($phpThumb->config_nooffsitelink_enabled && @$_SERVER['HTTP_REFERER'] && !in_array(@$parsed_url['host'], $phpThumb->config_nooffsitelink_valid_domains)) {
$phpThumb->DebugMessage('Would have used cached (image/'.$phpThumb->thumbnailFormat.') file "'.$phpThumb->cache_filename.'" (Last-Modified: '.gmdate('D, d M Y H:i:s', $nModified).' GMT), but skipping because $_SERVER[HTTP_REFERER] ('.@$_SERVER['HTTP_REFERER'].') is not in $phpThumb->config_nooffsitelink_valid_domains ('.implode(';', $phpThumb->config_nooffsitelink_valid_domains).')', __FILE__, __LINE__);
} elseif ($phpThumb->phpThumbDebug) {
$phpThumb->DebugTimingMessage('skipped using cached image', __FILE__, __LINE__);
$phpThumb->DebugMessage('Would have used cached file, but skipping due to phpThumbDebug', __FILE__, __LINE__);
$phpThumb->DebugMessage('* Would have sent headers (1): Last-Modified: '.gmdate('D, d M Y H:i:s', $nModified).' GMT', __FILE__, __LINE__);
if ($getimagesize = @GetImageSize($phpThumb->cache_filename)) {
$phpThumb->DebugMessage('* Would have sent headers (2): Content-Type: '.phpthumb_functions::ImageTypeToMIMEtype($getimagesize[2]), __FILE__, __LINE__);
}
if (ereg('^'.preg_quote($nice_docroot).'(.*)$', $nice_cachefile, $matches)) {
$phpThumb->DebugMessage('* Would have sent headers (3): Location: '.dirname($matches[1]).'/'.urlencode(basename($matches[1])), __FILE__, __LINE__);
} else {
$phpThumb->DebugMessage('* Would have sent data: readfile('.$phpThumb->cache_filename.')', __FILE__, __LINE__);
}
} else {
if (headers_sent()) {
$phpThumb->ErrorImage('Headers already sent ('.basename(__FILE__).' line '.__LINE__.')');
exit;
}
SendSaveAsFileHeaderIfNeeded();
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $nModified).' GMT');
if (@$_SERVER['HTTP_IF_MODIFIED_SINCE'] && ($nModified == strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) && @$_SERVER['SERVER_PROTOCOL']) {
header($_SERVER['SERVER_PROTOCOL'].' 304 Not Modified');
exit;
}
if ($getimagesize = @GetImageSize($phpThumb->cache_filename)) {
header('Content-Type: '.phpthumb_functions::ImageTypeToMIMEtype($getimagesize[2]));
} elseif (eregi('\.ico$', $phpThumb->cache_filename)) {
header('Content-Type: image/x-icon');
}
if (!@$PHPTHUMB_CONFIG['cache_force_passthru'] && ereg('^'.preg_quote($nice_docroot).'(.*)$', $nice_cachefile, $matches)) {
header('Location: '.dirname($matches[1]).'/'.urlencode(basename($matches[1])));
} else {
@readfile($phpThumb->cache_filename);
}
exit;
}
return true;
}
// check to see if file already exists in cache, and output it with no processing if it does
$phpThumb->SetCacheFilename();
if (@is_file($phpThumb->cache_filename)) {
RedirectToCachedFile();
} else {
$phpThumb->DebugMessage('Cached file "'.$phpThumb->cache_filename.'" does not exist, processing as normal', __FILE__, __LINE__);
}
////////////////////////////////////////////////////////////////
// Debug output, to try and help me diagnose problems
$phpThumb->DebugTimingMessage('phpThumbDebug[6]', __FILE__, __LINE__);
if (@$_GET['phpThumbDebug'] == '6') {
$phpThumb->phpThumbDebug();
}
////////////////////////////////////////////////////////////////
if ($phpThumb->rawImageData) {
// great
} elseif (@$_GET['new']) {
// generate a blank image resource of the specified size/background color/opacity
if (($phpThumb->w <= 0) || ($phpThumb->h <= 0)) {
$phpThumb->ErrorImage('"w" and "h" parameters required for "new"');
}
@list($bghexcolor, $opacity) = explode('|', $_GET['new']);
if (!phpthumb_functions::IsHexColor($bghexcolor)) {
$phpThumb->ErrorImage('BGcolor parameter for "new" is not valid');
}
$opacity = (strlen($opacity) ? $opacity : 100);
if ($phpThumb->gdimg_source = phpthumb_functions::ImageCreateFunction($phpThumb->w, $phpThumb->h)) {
$alpha = (100 - min(100, max(0, $opacity))) * 1.27;
if ($alpha) {
$phpThumb->setParameter('is_alpha', true);
ImageAlphaBlending($phpThumb->gdimg_source, false);
phpthumb_functions::gd_ImageSaveAlpha($phpThumb->gdimg_source, true);
}
$new_background_color = phpthumb_functions::ImageHexColorAllocate($phpThumb->gdimg_source, $bghexcolor, false, $alpha);
ImageFilledRectangle($phpThumb->gdimg_source, 0, 0, $phpThumb->w, $phpThumb->h, $new_background_color);
} else {
$phpThumb->ErrorImage('failed to create "new" image ('.$phpThumb->w.'x'.$phpThumb->h.')');
}
} elseif (!$phpThumb->src) {
$phpThumb->ErrorImage('Usage: '.$_SERVER['PHP_SELF'].'?src=/path/and/filename.jpg'."\n".'read Usage comments for details');
} elseif (eregi('^(f|ht)tp\://', $phpThumb->src)) {
if ($phpThumb->config_http_user_agent) {
ini_set('user_agent', $phpThumb->config_http_user_agent);
}
$basename = preg_quote(basename($phpThumb->src));
$encoded = rawurlencode(basename($phpThumb->src));
$HTTPurl = ereg_replace('(.*)'.$basename.'$', '\\1'.$encoded, $phpThumb->src);
if ($rawImageData = phpthumb_functions::SafeURLread($HTTPurl, $error)) {
$phpThumb->setSourceData($rawImageData, urlencode($phpThumb->src));
} else {
$phpThumb->ErrorImage($error);
}
}
////////////////////////////////////////////////////////////////
// Debug output, to try and help me diagnose problems
$phpThumb->DebugTimingMessage('phpThumbDebug[7]', __FILE__, __LINE__);
if (@$_GET['phpThumbDebug'] == '7') {
$phpThumb->phpThumbDebug();
}
////////////////////////////////////////////////////////////////
$phpThumb->GenerateThumbnail();
////////////////////////////////////////////////////////////////
// Debug output, to try and help me diagnose problems
$phpThumb->DebugTimingMessage('phpThumbDebug[8]', __FILE__, __LINE__);
if (@$_GET['phpThumbDebug'] == '8') {
$phpThumb->phpThumbDebug();
}
////////////////////////////////////////////////////////////////
if ($phpThumb->config_allow_parameter_file && $phpThumb->file) {
$phpThumb->RenderToFile($phpThumb->ResolveFilenameToAbsolute($phpThumb->file));
if ($phpThumb->config_allow_parameter_goto && $phpThumb->goto && eregi('^(f|ht)tps?://', $phpThumb->goto)) {
// redirect to another URL after image has been rendered to file
header('Location: '.$phpThumb->goto);
exit;
}
} else {
if ((file_exists($phpThumb->cache_filename) && is_writable($phpThumb->cache_filename)) || is_writable(dirname($phpThumb->cache_filename))) {
$phpThumb->CleanUpCacheDirectory();
if ($phpThumb->RenderToFile($phpThumb->cache_filename) && is_readable($phpThumb->cache_filename)) {
chmod($phpThumb->cache_filename, 0644);
RedirectToCachedFile();
} else {
$phpThumb->DebugMessage('Failed: RenderToFile('.$phpThumb->cache_filename.')', __FILE__, __LINE__);
}
} else {
$phpThumb->DebugMessage('Cannot write to $phpThumb->cache_filename ('.$phpThumb->cache_filename.') because that directory ('.dirname($phpThumb->cache_filename).') is not writable', __FILE__, __LINE__);
}
}
////////////////////////////////////////////////////////////////
// Debug output, to try and help me diagnose problems
$phpThumb->DebugTimingMessage('phpThumbDebug[9]', __FILE__, __LINE__);
if (@$_GET['phpThumbDebug'] == '9') {
$phpThumb->phpThumbDebug();
}
////////////////////////////////////////////////////////////////
if (!$phpThumb->OutputThumbnail()) {
$phpThumb->ErrorImage('Error in OutputThumbnail():'."\n".$phpThumb->debugmessages[(count($phpThumb->debugmessages) - 1)]);
}
////////////////////////////////////////////////////////////////
// Debug output, to try and help me diagnose problems
$phpThumb->DebugTimingMessage('phpThumbDebug[10]', __FILE__, __LINE__);
if (@$_GET['phpThumbDebug'] == '10') {
$phpThumb->phpThumbDebug();
}
////////////////////////////////////////////////////////////////
?>

View File

@ -0,0 +1,874 @@
<?php
/////////////////////////////////////////////////////////////////
/// getID3() by James Heinrich <info@getid3.org> //
// available at http://getid3.sourceforge.net //
// or http://www.getid3.org //
/////////////////////////////////////////////////////////////////
// See readme.txt for more details //
/////////////////////////////////////////////////////////////////
// //
// module.graphic.bmp.php //
// module for analyzing BMP Image files //
// dependencies: NONE //
// ///
/////////////////////////////////////////////////////////////////
// //
// Modified for use in phpThumb() - James Heinrich 2004.07.27 //
// //
/////////////////////////////////////////////////////////////////
class phpthumb_bmp {
function phpthumb_bmp() {
return true;
}
function phpthumb_bmp2gd(&$BMPdata, $truecolor=true) {
$ThisFileInfo = array();
if ($this->getid3_bmp($BMPdata, $ThisFileInfo, true, true)) {
$gd = $this->PlotPixelsGD($ThisFileInfo['bmp'], $truecolor);
return $gd;
}
return false;
}
function phpthumb_bmpfile2gd($filename, $truecolor=true) {
if ($fp = @fopen($filename, 'rb')) {
$BMPdata = fread($fp, filesize($filename));
fclose($fp);
return $this->phpthumb_bmp2gd($BMPdata, $truecolor);
}
return false;
}
function GD2BMPstring(&$gd_image) {
$imageX = ImageSX($gd_image);
$imageY = ImageSY($gd_image);
$BMP = '';
for ($y = ($imageY - 1); $y >= 0; $y--) {
$thisline = '';
for ($x = 0; $x < $imageX; $x++) {
$argb = phpthumb_functions::GetPixelColor($gd_image, $x, $y);
$thisline .= chr($argb['blue']).chr($argb['green']).chr($argb['red']);
}
while (strlen($thisline) % 4) {
$thisline .= "\x00";
}
$BMP .= $thisline;
}
$bmpSize = strlen($BMP) + 14 + 40;
// BITMAPFILEHEADER [14 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_62uq.asp
$BITMAPFILEHEADER = 'BM'; // WORD bfType;
$BITMAPFILEHEADER .= phpthumb_functions::LittleEndian2String($bmpSize, 4); // DWORD bfSize;
$BITMAPFILEHEADER .= phpthumb_functions::LittleEndian2String( 0, 2); // WORD bfReserved1;
$BITMAPFILEHEADER .= phpthumb_functions::LittleEndian2String( 0, 2); // WORD bfReserved2;
$BITMAPFILEHEADER .= phpthumb_functions::LittleEndian2String( 54, 4); // DWORD bfOffBits;
// BITMAPINFOHEADER - [40 bytes] http://msdn.microsoft.com/library/en-us/gdi/bitmaps_1rw2.asp
$BITMAPINFOHEADER = phpthumb_functions::LittleEndian2String( 40, 4); // DWORD biSize;
$BITMAPINFOHEADER .= phpthumb_functions::LittleEndian2String( $imageX, 4); // LONG biWidth;
$BITMAPINFOHEADER .= phpthumb_functions::LittleEndian2String( $imageY, 4); // LONG biHeight;
$BITMAPINFOHEADER .= phpthumb_functions::LittleEndian2String( 1, 2); // WORD biPlanes;
$BITMAPINFOHEADER .= phpthumb_functions::LittleEndian2String( 24, 2); // WORD biBitCount;
$BITMAPINFOHEADER .= phpthumb_functions::LittleEndian2String( 0, 4); // DWORD biCompression;
$BITMAPINFOHEADER .= phpthumb_functions::LittleEndian2String( 0, 4); // DWORD biSizeImage;
$BITMAPINFOHEADER .= phpthumb_functions::LittleEndian2String( 2835, 4); // LONG biXPelsPerMeter;
$BITMAPINFOHEADER .= phpthumb_functions::LittleEndian2String( 2835, 4); // LONG biYPelsPerMeter;
$BITMAPINFOHEADER .= phpthumb_functions::LittleEndian2String( 0, 4); // DWORD biClrUsed;
$BITMAPINFOHEADER .= phpthumb_functions::LittleEndian2String( 0, 4); // DWORD biClrImportant;
return $BITMAPFILEHEADER.$BITMAPINFOHEADER.$BMP;
}
function getid3_bmp(&$BMPdata, &$ThisFileInfo, $ExtractPalette=false, $ExtractData=false) {
// shortcuts
$ThisFileInfo['bmp']['header']['raw'] = array();
$thisfile_bmp = &$ThisFileInfo['bmp'];
$thisfile_bmp_header = &$thisfile_bmp['header'];
$thisfile_bmp_header_raw = &$thisfile_bmp_header['raw'];
// BITMAPFILEHEADER [14 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_62uq.asp
// all versions
// WORD bfType;
// DWORD bfSize;
// WORD bfReserved1;
// WORD bfReserved2;
// DWORD bfOffBits;
$offset = 0;
$overalloffset = 0;
$BMPheader = substr($BMPdata, $overalloffset, 14 + 40);
$overalloffset += (14 + 40);
$thisfile_bmp_header_raw['identifier'] = substr($BMPheader, $offset, 2);
$offset += 2;
if ($thisfile_bmp_header_raw['identifier'] != 'BM') {
$ThisFileInfo['error'][] = 'Expecting "BM" at offset '.$ThisFileInfo['avdataoffset'].', found "'.$thisfile_bmp_header_raw['identifier'].'"';
unset($ThisFileInfo['fileformat']);
unset($ThisFileInfo['bmp']);
return false;
}
$thisfile_bmp_header_raw['filesize'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['reserved1'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
$offset += 2;
$thisfile_bmp_header_raw['reserved2'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
$offset += 2;
$thisfile_bmp_header_raw['data_offset'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['header_size'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
// check if the hardcoded-to-1 "planes" is at offset 22 or 26
$planes22 = $this->LittleEndian2Int(substr($BMPheader, 22, 2));
$planes26 = $this->LittleEndian2Int(substr($BMPheader, 26, 2));
if (($planes22 == 1) && ($planes26 != 1)) {
$thisfile_bmp['type_os'] = 'OS/2';
$thisfile_bmp['type_version'] = 1;
} elseif (($planes26 == 1) && ($planes22 != 1)) {
$thisfile_bmp['type_os'] = 'Windows';
$thisfile_bmp['type_version'] = 1;
} elseif ($thisfile_bmp_header_raw['header_size'] == 12) {
$thisfile_bmp['type_os'] = 'OS/2';
$thisfile_bmp['type_version'] = 1;
} elseif ($thisfile_bmp_header_raw['header_size'] == 40) {
$thisfile_bmp['type_os'] = 'Windows';
$thisfile_bmp['type_version'] = 1;
} elseif ($thisfile_bmp_header_raw['header_size'] == 84) {
$thisfile_bmp['type_os'] = 'Windows';
$thisfile_bmp['type_version'] = 4;
} elseif ($thisfile_bmp_header_raw['header_size'] == 100) {
$thisfile_bmp['type_os'] = 'Windows';
$thisfile_bmp['type_version'] = 5;
} else {
$ThisFileInfo['error'][] = 'Unknown BMP subtype (or not a BMP file)';
unset($ThisFileInfo['fileformat']);
unset($ThisFileInfo['bmp']);
return false;
}
$ThisFileInfo['fileformat'] = 'bmp';
$ThisFileInfo['video']['dataformat'] = 'bmp';
$ThisFileInfo['video']['lossless'] = true;
$ThisFileInfo['video']['pixel_aspect_ratio'] = (float) 1;
if ($thisfile_bmp['type_os'] == 'OS/2') {
// OS/2-format BMP
// http://netghost.narod.ru/gff/graphics/summary/os2bmp.htm
// DWORD Size; /* Size of this structure in bytes */
// DWORD Width; /* Bitmap width in pixels */
// DWORD Height; /* Bitmap height in pixel */
// WORD NumPlanes; /* Number of bit planes (color depth) */
// WORD BitsPerPixel; /* Number of bits per pixel per plane */
$thisfile_bmp_header_raw['width'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
$offset += 2;
$thisfile_bmp_header_raw['height'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
$offset += 2;
$thisfile_bmp_header_raw['planes'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
$offset += 2;
$thisfile_bmp_header_raw['bits_per_pixel'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
$offset += 2;
$ThisFileInfo['video']['resolution_x'] = $thisfile_bmp_header_raw['width'];
$ThisFileInfo['video']['resolution_y'] = $thisfile_bmp_header_raw['height'];
$ThisFileInfo['video']['codec'] = 'BI_RGB '.$thisfile_bmp_header_raw['bits_per_pixel'].'-bit';
$ThisFileInfo['video']['bits_per_sample'] = $thisfile_bmp_header_raw['bits_per_pixel'];
if ($thisfile_bmp['type_version'] >= 2) {
// DWORD Compression; /* Bitmap compression scheme */
// DWORD ImageDataSize; /* Size of bitmap data in bytes */
// DWORD XResolution; /* X resolution of display device */
// DWORD YResolution; /* Y resolution of display device */
// DWORD ColorsUsed; /* Number of color table indices used */
// DWORD ColorsImportant; /* Number of important color indices */
// WORD Units; /* Type of units used to measure resolution */
// WORD Reserved; /* Pad structure to 4-byte boundary */
// WORD Recording; /* Recording algorithm */
// WORD Rendering; /* Halftoning algorithm used */
// DWORD Size1; /* Reserved for halftoning algorithm use */
// DWORD Size2; /* Reserved for halftoning algorithm use */
// DWORD ColorEncoding; /* Color model used in bitmap */
// DWORD Identifier; /* Reserved for application use */
$thisfile_bmp_header_raw['compression'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['bmp_data_size'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['resolution_h'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['resolution_v'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['colors_used'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['colors_important'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['resolution_units'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
$offset += 2;
$thisfile_bmp_header_raw['reserved1'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
$offset += 2;
$thisfile_bmp_header_raw['recording'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
$offset += 2;
$thisfile_bmp_header_raw['rendering'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
$offset += 2;
$thisfile_bmp_header_raw['size1'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['size2'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['color_encoding'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['identifier'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header['compression'] = $this->BMPcompressionOS2Lookup($thisfile_bmp_header_raw['compression']);
$ThisFileInfo['video']['codec'] = $thisfile_bmp_header['compression'].' '.$thisfile_bmp_header_raw['bits_per_pixel'].'-bit';
}
} elseif ($thisfile_bmp['type_os'] == 'Windows') {
// Windows-format BMP
// BITMAPINFOHEADER - [40 bytes] http://msdn.microsoft.com/library/en-us/gdi/bitmaps_1rw2.asp
// all versions
// DWORD biSize;
// LONG biWidth;
// LONG biHeight;
// WORD biPlanes;
// WORD biBitCount;
// DWORD biCompression;
// DWORD biSizeImage;
// LONG biXPelsPerMeter;
// LONG biYPelsPerMeter;
// DWORD biClrUsed;
// DWORD biClrImportant;
$thisfile_bmp_header_raw['width'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4), true);
$offset += 4;
$thisfile_bmp_header_raw['height'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4), true);
$offset += 4;
$thisfile_bmp_header_raw['planes'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
$offset += 2;
$thisfile_bmp_header_raw['bits_per_pixel'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 2));
$offset += 2;
$thisfile_bmp_header_raw['compression'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['bmp_data_size'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['resolution_h'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4), true);
$offset += 4;
$thisfile_bmp_header_raw['resolution_v'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4), true);
$offset += 4;
$thisfile_bmp_header_raw['colors_used'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['colors_important'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header['compression'] = $this->BMPcompressionWindowsLookup($thisfile_bmp_header_raw['compression']);
$ThisFileInfo['video']['resolution_x'] = $thisfile_bmp_header_raw['width'];
$ThisFileInfo['video']['resolution_y'] = $thisfile_bmp_header_raw['height'];
$ThisFileInfo['video']['codec'] = $thisfile_bmp_header['compression'].' '.$thisfile_bmp_header_raw['bits_per_pixel'].'-bit';
$ThisFileInfo['video']['bits_per_sample'] = $thisfile_bmp_header_raw['bits_per_pixel'];
if (($thisfile_bmp['type_version'] >= 4) || ($thisfile_bmp_header_raw['compression'] == 3)) {
// should only be v4+, but BMPs with type_version==1 and BI_BITFIELDS compression have been seen
$BMPheader .= substr($BMPdata, $overalloffset, 44);
$overalloffset += 44;
// BITMAPV4HEADER - [44 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_2k1e.asp
// Win95+, WinNT4.0+
// DWORD bV4RedMask;
// DWORD bV4GreenMask;
// DWORD bV4BlueMask;
// DWORD bV4AlphaMask;
// DWORD bV4CSType;
// CIEXYZTRIPLE bV4Endpoints;
// DWORD bV4GammaRed;
// DWORD bV4GammaGreen;
// DWORD bV4GammaBlue;
$thisfile_bmp_header_raw['red_mask'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['green_mask'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['blue_mask'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['alpha_mask'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['cs_type'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['ciexyz_red'] = substr($BMPheader, $offset, 4);
$offset += 4;
$thisfile_bmp_header_raw['ciexyz_green'] = substr($BMPheader, $offset, 4);
$offset += 4;
$thisfile_bmp_header_raw['ciexyz_blue'] = substr($BMPheader, $offset, 4);
$offset += 4;
$thisfile_bmp_header_raw['gamma_red'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['gamma_green'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['gamma_blue'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header['ciexyz_red'] = $this->FixedPoint2_30(strrev($thisfile_bmp_header_raw['ciexyz_red']));
$thisfile_bmp_header['ciexyz_green'] = $this->FixedPoint2_30(strrev($thisfile_bmp_header_raw['ciexyz_green']));
$thisfile_bmp_header['ciexyz_blue'] = $this->FixedPoint2_30(strrev($thisfile_bmp_header_raw['ciexyz_blue']));
}
if ($thisfile_bmp['type_version'] >= 5) {
$BMPheader .= substr($BMPdata, $overalloffset, 16);
$overalloffset += 16;
// BITMAPV5HEADER - [16 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_7c36.asp
// Win98+, Win2000+
// DWORD bV5Intent;
// DWORD bV5ProfileData;
// DWORD bV5ProfileSize;
// DWORD bV5Reserved;
$thisfile_bmp_header_raw['intent'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['profile_data_offset'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['profile_data_size'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
$thisfile_bmp_header_raw['reserved3'] = $this->LittleEndian2Int(substr($BMPheader, $offset, 4));
$offset += 4;
}
} else {
$ThisFileInfo['error'][] = 'Unknown BMP format in header.';
return false;
}
if ($ExtractPalette || $ExtractData) {
$PaletteEntries = 0;
if ($thisfile_bmp_header_raw['bits_per_pixel'] < 16) {
$PaletteEntries = pow(2, $thisfile_bmp_header_raw['bits_per_pixel']);
} elseif (isset($thisfile_bmp_header_raw['colors_used']) && ($thisfile_bmp_header_raw['colors_used'] > 0) && ($thisfile_bmp_header_raw['colors_used'] <= 256)) {
$PaletteEntries = $thisfile_bmp_header_raw['colors_used'];
}
if ($PaletteEntries > 0) {
$BMPpalette = substr($BMPdata, $overalloffset, 4 * $PaletteEntries);
$overalloffset += 4 * $PaletteEntries;
$paletteoffset = 0;
for ($i = 0; $i < $PaletteEntries; $i++) {
// RGBQUAD - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_5f8y.asp
// BYTE rgbBlue;
// BYTE rgbGreen;
// BYTE rgbRed;
// BYTE rgbReserved;
$blue = $this->LittleEndian2Int(substr($BMPpalette, $paletteoffset++, 1));
$green = $this->LittleEndian2Int(substr($BMPpalette, $paletteoffset++, 1));
$red = $this->LittleEndian2Int(substr($BMPpalette, $paletteoffset++, 1));
if (($thisfile_bmp['type_os'] == 'OS/2') && ($thisfile_bmp['type_version'] == 1)) {
// no padding byte
} else {
$paletteoffset++; // padding byte
}
$thisfile_bmp['palette'][$i] = (($red << 16) | ($green << 8) | ($blue));
}
}
}
if ($ExtractData) {
$RowByteLength = ceil(($thisfile_bmp_header_raw['width'] * ($thisfile_bmp_header_raw['bits_per_pixel'] / 8)) / 4) * 4; // round up to nearest DWORD boundry
$BMPpixelData = substr($BMPdata, $thisfile_bmp_header_raw['data_offset'], $thisfile_bmp_header_raw['height'] * $RowByteLength);
$overalloffset = $thisfile_bmp_header_raw['data_offset'] + ($thisfile_bmp_header_raw['height'] * $RowByteLength);
$pixeldataoffset = 0;
switch (@$thisfile_bmp_header_raw['compression']) {
case 0: // BI_RGB
switch ($thisfile_bmp_header_raw['bits_per_pixel']) {
case 1:
for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col = $col) {
$paletteindexbyte = ord($BMPpixelData{$pixeldataoffset++});
for ($i = 7; $i >= 0; $i--) {
$paletteindex = ($paletteindexbyte & (0x01 << $i)) >> $i;
$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindex];
$col++;
}
}
while (($pixeldataoffset % 4) != 0) {
// lines are padded to nearest DWORD
$pixeldataoffset++;
}
}
break;
case 4:
for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col = $col) {
$paletteindexbyte = ord($BMPpixelData{$pixeldataoffset++});
for ($i = 1; $i >= 0; $i--) {
$paletteindex = ($paletteindexbyte & (0x0F << (4 * $i))) >> (4 * $i);
$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindex];
$col++;
}
}
while (($pixeldataoffset % 4) != 0) {
// lines are padded to nearest DWORD
$pixeldataoffset++;
}
}
break;
case 8:
for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col++) {
$paletteindex = ord($BMPpixelData{$pixeldataoffset++});
$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindex];
}
while (($pixeldataoffset % 4) != 0) {
// lines are padded to nearest DWORD
$pixeldataoffset++;
}
}
break;
case 24:
for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col++) {
$thisfile_bmp['data'][$row][$col] = (ord($BMPpixelData{$pixeldataoffset+2}) << 16) | (ord($BMPpixelData{$pixeldataoffset+1}) << 8) | ord($BMPpixelData{$pixeldataoffset});
$pixeldataoffset += 3;
}
while (($pixeldataoffset % 4) != 0) {
// lines are padded to nearest DWORD
$pixeldataoffset++;
}
}
break;
case 32:
for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col++) {
$thisfile_bmp['data'][$row][$col] = (ord($BMPpixelData{$pixeldataoffset+3}) << 24) | (ord($BMPpixelData{$pixeldataoffset+2}) << 16) | (ord($BMPpixelData{$pixeldataoffset+1}) << 8) | ord($BMPpixelData{$pixeldataoffset});
$pixeldataoffset += 4;
}
while (($pixeldataoffset % 4) != 0) {
// lines are padded to nearest DWORD
$pixeldataoffset++;
}
}
break;
case 16:
// ?
break;
default:
$ThisFileInfo['error'][] = 'Unknown bits-per-pixel value ('.$thisfile_bmp_header_raw['bits_per_pixel'].') - cannot read pixel data';
break;
}
break;
case 1: // BI_RLE8 - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_6x0u.asp
switch ($thisfile_bmp_header_raw['bits_per_pixel']) {
case 8:
$pixelcounter = 0;
while ($pixeldataoffset < strlen($BMPpixelData)) {
$firstbyte = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
$secondbyte = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
if ($firstbyte == 0) {
// escaped/absolute mode - the first byte of the pair can be set to zero to
// indicate an escape character that denotes the end of a line, the end of
// a bitmap, or a delta, depending on the value of the second byte.
switch ($secondbyte) {
case 0:
// end of line
// no need for special processing, just ignore
break;
case 1:
// end of bitmap
$pixeldataoffset = strlen($BMPpixelData); // force to exit loop just in case
break;
case 2:
// delta - The 2 bytes following the escape contain unsigned values
// indicating the horizontal and vertical offsets of the next pixel
// from the current position.
$colincrement = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
$rowincrement = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
$col = ($pixelcounter % $thisfile_bmp_header_raw['width']) + $colincrement;
$row = ($thisfile_bmp_header_raw['height'] - 1 - (($pixelcounter - $col) / $thisfile_bmp_header_raw['width'])) - $rowincrement;
$pixelcounter = ($row * $thisfile_bmp_header_raw['width']) + $col;
break;
default:
// In absolute mode, the first byte is zero and the second byte is a
// value in the range 03H through FFH. The second byte represents the
// number of bytes that follow, each of which contains the color index
// of a single pixel. Each run must be aligned on a word boundary.
for ($i = 0; $i < $secondbyte; $i++) {
$paletteindex = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
$col = $pixelcounter % $thisfile_bmp_header_raw['width'];
$row = $thisfile_bmp_header_raw['height'] - 1 - (($pixelcounter - $col) / $thisfile_bmp_header_raw['width']);
$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindex];
$pixelcounter++;
}
while (($pixeldataoffset % 2) != 0) {
// Each run must be aligned on a word boundary.
$pixeldataoffset++;
}
break;
}
} else {
// encoded mode - the first byte specifies the number of consecutive pixels
// to be drawn using the color index contained in the second byte.
for ($i = 0; $i < $firstbyte; $i++) {
$col = $pixelcounter % $thisfile_bmp_header_raw['width'];
$row = $thisfile_bmp_header_raw['height'] - 1 - (($pixelcounter - $col) / $thisfile_bmp_header_raw['width']);
$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$secondbyte];
$pixelcounter++;
}
}
}
break;
default:
$ThisFileInfo['error'][] = 'Unknown bits-per-pixel value ('.$thisfile_bmp_header_raw['bits_per_pixel'].') - cannot read pixel data';
break;
}
break;
case 2: // BI_RLE4 - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_6x0u.asp
switch ($thisfile_bmp_header_raw['bits_per_pixel']) {
case 4:
$pixelcounter = 0;
while ($pixeldataoffset < strlen($BMPpixelData)) {
$firstbyte = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
$secondbyte = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
if ($firstbyte == 0) {
// escaped/absolute mode - the first byte of the pair can be set to zero to
// indicate an escape character that denotes the end of a line, the end of
// a bitmap, or a delta, depending on the value of the second byte.
switch ($secondbyte) {
case 0:
// end of line
// no need for special processing, just ignore
break;
case 1:
// end of bitmap
$pixeldataoffset = strlen($BMPpixelData); // force to exit loop just in case
break;
case 2:
// delta - The 2 bytes following the escape contain unsigned values
// indicating the horizontal and vertical offsets of the next pixel
// from the current position.
$colincrement = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
$rowincrement = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
$col = ($pixelcounter % $thisfile_bmp_header_raw['width']) + $colincrement;
$row = ($thisfile_bmp_header_raw['height'] - 1 - (($pixelcounter - $col) / $thisfile_bmp_header_raw['width'])) - $rowincrement;
$pixelcounter = ($row * $thisfile_bmp_header_raw['width']) + $col;
break;
default:
// In absolute mode, the first byte is zero. The second byte contains the number
// of color indexes that follow. Subsequent bytes contain color indexes in their
// high- and low-order 4 bits, one color index for each pixel. In absolute mode,
// each run must be aligned on a word boundary.
unset($paletteindexes);
for ($i = 0; $i < ceil($secondbyte / 2); $i++) {
$paletteindexbyte = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset++, 1));
$paletteindexes[] = ($paletteindexbyte & 0xF0) >> 4;
$paletteindexes[] = ($paletteindexbyte & 0x0F);
}
while (($pixeldataoffset % 2) != 0) {
// Each run must be aligned on a word boundary.
$pixeldataoffset++;
}
foreach ($paletteindexes as $dummy => $paletteindex) {
$col = $pixelcounter % $thisfile_bmp_header_raw['width'];
$row = $thisfile_bmp_header_raw['height'] - 1 - (($pixelcounter - $col) / $thisfile_bmp_header_raw['width']);
$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindex];
$pixelcounter++;
}
break;
}
} else {
// encoded mode - the first byte of the pair contains the number of pixels to be
// drawn using the color indexes in the second byte. The second byte contains two
// color indexes, one in its high-order 4 bits and one in its low-order 4 bits.
// The first of the pixels is drawn using the color specified by the high-order
// 4 bits, the second is drawn using the color in the low-order 4 bits, the third
// is drawn using the color in the high-order 4 bits, and so on, until all the
// pixels specified by the first byte have been drawn.
$paletteindexes[0] = ($secondbyte & 0xF0) >> 4;
$paletteindexes[1] = ($secondbyte & 0x0F);
for ($i = 0; $i < $firstbyte; $i++) {
$col = $pixelcounter % $thisfile_bmp_header_raw['width'];
$row = $thisfile_bmp_header_raw['height'] - 1 - (($pixelcounter - $col) / $thisfile_bmp_header_raw['width']);
$thisfile_bmp['data'][$row][$col] = $thisfile_bmp['palette'][$paletteindexes[($i % 2)]];
$pixelcounter++;
}
}
}
break;
default:
$ThisFileInfo['error'][] = 'Unknown bits-per-pixel value ('.$thisfile_bmp_header_raw['bits_per_pixel'].') - cannot read pixel data';
break;
}
break;
case 3: // BI_BITFIELDS
switch ($thisfile_bmp_header_raw['bits_per_pixel']) {
case 16:
case 32:
$redshift = 0;
$greenshift = 0;
$blueshift = 0;
if (!$thisfile_bmp_header_raw['red_mask'] || !$thisfile_bmp_header_raw['green_mask'] || !$thisfile_bmp_header_raw['blue_mask']) {
$ThisFileInfo['error'][] = 'missing $thisfile_bmp_header_raw[(red|green|blue)_mask]';
return false;
}
while ((($thisfile_bmp_header_raw['red_mask'] >> $redshift) & 0x01) == 0) {
$redshift++;
}
while ((($thisfile_bmp_header_raw['green_mask'] >> $greenshift) & 0x01) == 0) {
$greenshift++;
}
while ((($thisfile_bmp_header_raw['blue_mask'] >> $blueshift) & 0x01) == 0) {
$blueshift++;
}
for ($row = ($thisfile_bmp_header_raw['height'] - 1); $row >= 0; $row--) {
for ($col = 0; $col < $thisfile_bmp_header_raw['width']; $col++) {
$pixelvalue = $this->LittleEndian2Int(substr($BMPpixelData, $pixeldataoffset, $thisfile_bmp_header_raw['bits_per_pixel'] / 8));
$pixeldataoffset += $thisfile_bmp_header_raw['bits_per_pixel'] / 8;
$red = intval(round(((($pixelvalue & $thisfile_bmp_header_raw['red_mask']) >> $redshift) / ($thisfile_bmp_header_raw['red_mask'] >> $redshift)) * 255));
$green = intval(round(((($pixelvalue & $thisfile_bmp_header_raw['green_mask']) >> $greenshift) / ($thisfile_bmp_header_raw['green_mask'] >> $greenshift)) * 255));
$blue = intval(round(((($pixelvalue & $thisfile_bmp_header_raw['blue_mask']) >> $blueshift) / ($thisfile_bmp_header_raw['blue_mask'] >> $blueshift)) * 255));
$thisfile_bmp['data'][$row][$col] = (($red << 16) | ($green << 8) | ($blue));
}
while (($pixeldataoffset % 4) != 0) {
// lines are padded to nearest DWORD
$pixeldataoffset++;
}
}
break;
default:
$ThisFileInfo['error'][] = 'Unknown bits-per-pixel value ('.$thisfile_bmp_header_raw['bits_per_pixel'].') - cannot read pixel data';
break;
}
break;
default: // unhandled compression type
$ThisFileInfo['error'][] = 'Unknown/unhandled compression type value ('.$thisfile_bmp_header_raw['compression'].') - cannot decompress pixel data';
break;
}
}
return true;
}
function IntColor2RGB($color) {
$red = ($color & 0x00FF0000) >> 16;
$green = ($color & 0x0000FF00) >> 8;
$blue = ($color & 0x000000FF);
return array($red, $green, $blue);
}
function PlotPixelsGD(&$BMPdata, $truecolor=true) {
$imagewidth = $BMPdata['header']['raw']['width'];
$imageheight = $BMPdata['header']['raw']['height'];
if ($truecolor) {
$gd = @ImageCreateTrueColor($imagewidth, $imageheight);
} else {
$gd = @ImageCreate($imagewidth, $imageheight);
if (!empty($BMPdata['palette'])) {
// create GD palette from BMP palette
foreach ($BMPdata['palette'] as $dummy => $color) {
list($r, $g, $b) = $this->IntColor2RGB($color);
ImageColorAllocate($gd, $r, $g, $b);
}
} else {
// create 216-color websafe palette
for ($r = 0x00; $r <= 0xFF; $r += 0x33) {
for ($g = 0x00; $g <= 0xFF; $g += 0x33) {
for ($b = 0x00; $b <= 0xFF; $b += 0x33) {
ImageColorAllocate($gd, $r, $g, $b);
}
}
}
}
}
if (!is_resource($gd)) {
return false;
}
foreach ($BMPdata['data'] as $row => $colarray) {
@set_time_limit(30);
foreach ($colarray as $col => $color) {
list($red, $green, $blue) = $this->IntColor2RGB($color);
if ($truecolor) {
$pixelcolor = ImageColorAllocate($gd, $red, $green, $blue);
} else {
$pixelcolor = ImageColorClosest($gd, $red, $green, $blue);
}
ImageSetPixel($gd, $col, $row, $pixelcolor);
}
}
return $gd;
}
function PlotBMP(&$BMPinfo) {
$starttime = time();
if (!isset($BMPinfo['bmp']['data']) || !is_array($BMPinfo['bmp']['data'])) {
echo 'ERROR: no pixel data<BR>';
return false;
}
set_time_limit(intval(round($BMPinfo['resolution_x'] * $BMPinfo['resolution_y'] / 10000)));
$im = $this->PlotPixelsGD($BMPinfo['bmp']);
if (headers_sent()) {
echo 'plotted '.($BMPinfo['resolution_x'] * $BMPinfo['resolution_y']).' pixels in '.(time() - $starttime).' seconds<BR>';
ImageDestroy($im);
exit;
} else {
header('Content-Type: image/png');
ImagePNG($im);
ImageDestroy($im);
return true;
}
return false;
}
function BMPcompressionWindowsLookup($compressionid) {
static $BMPcompressionWindowsLookup = array(
0 => 'BI_RGB',
1 => 'BI_RLE8',
2 => 'BI_RLE4',
3 => 'BI_BITFIELDS',
4 => 'BI_JPEG',
5 => 'BI_PNG'
);
return (isset($BMPcompressionWindowsLookup[$compressionid]) ? $BMPcompressionWindowsLookup[$compressionid] : 'invalid');
}
function BMPcompressionOS2Lookup($compressionid) {
static $BMPcompressionOS2Lookup = array(
0 => 'BI_RGB',
1 => 'BI_RLE8',
2 => 'BI_RLE4',
3 => 'Huffman 1D',
4 => 'BI_RLE24',
);
return (isset($BMPcompressionOS2Lookup[$compressionid]) ? $BMPcompressionOS2Lookup[$compressionid] : 'invalid');
}
// from getid3.lib.php
function trunc($floatnumber) {
// truncates a floating-point number at the decimal point
// returns int (if possible, otherwise float)
if ($floatnumber >= 1) {
$truncatednumber = floor($floatnumber);
} elseif ($floatnumber <= -1) {
$truncatednumber = ceil($floatnumber);
} else {
$truncatednumber = 0;
}
if ($truncatednumber <= 1073741824) { // 2^30
$truncatednumber = (int) $truncatednumber;
}
return $truncatednumber;
}
function LittleEndian2Int($byteword) {
$intvalue = 0;
$byteword = strrev($byteword);
$bytewordlen = strlen($byteword);
for ($i = 0; $i < $bytewordlen; $i++) {
$intvalue += ord($byteword{$i}) * pow(256, ($bytewordlen - 1 - $i));
}
return $intvalue;
}
function BigEndian2Int($byteword) {
return $this->LittleEndian2Int(strrev($byteword));
}
function BigEndian2Bin($byteword) {
$binvalue = '';
$bytewordlen = strlen($byteword);
for ($i = 0; $i < $bytewordlen; $i++) {
$binvalue .= str_pad(decbin(ord($byteword{$i})), 8, '0', STR_PAD_LEFT);
}
return $binvalue;
}
function FixedPoint2_30($rawdata) {
$binarystring = $this->BigEndian2Bin($rawdata);
return $this->Bin2Dec(substr($binarystring, 0, 2)) + (float) ($this->Bin2Dec(substr($binarystring, 2, 30)) / 1073741824);
}
function Bin2Dec($binstring, $signed=false) {
$signmult = 1;
if ($signed) {
if ($binstring{0} == '1') {
$signmult = -1;
}
$binstring = substr($binstring, 1);
}
$decvalue = 0;
for ($i = 0; $i < strlen($binstring); $i++) {
$decvalue += ((int) substr($binstring, strlen($binstring) - $i - 1, 1)) * pow(2, $i);
}
return $this->CastAsInt($decvalue * $signmult);
}
function CastAsInt($floatnum) {
// convert to float if not already
$floatnum = (float) $floatnum;
// convert a float to type int, only if possible
if ($this->trunc($floatnum) == $floatnum) {
// it's not floating point
if ($floatnum <= 1073741824) { // 2^30
// it's within int range
$floatnum = (int) $floatnum;
}
}
return $floatnum;
}
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,707 @@
<?php
//////////////////////////////////////////////////////////////
/// phpThumb() by James Heinrich <info@silisoftware.com> //
// available at http://phpthumb.sourceforge.net ///
//////////////////////////////////////////////////////////////
/// //
// phpthumb.functions.php - general support functions //
// ///
//////////////////////////////////////////////////////////////
class phpthumb_functions {
function user_function_exists($functionname) {
if (function_exists('get_defined_functions')) {
static $get_defined_functions = array();
if (empty($get_defined_functions)) {
$get_defined_functions = get_defined_functions();
}
return in_array(strtolower($functionname), $get_defined_functions['user']);
}
return function_exists($functionname);
}
function builtin_function_exists($functionname) {
if (function_exists('get_defined_functions')) {
static $get_defined_functions = array();
if (empty($get_defined_functions)) {
$get_defined_functions = get_defined_functions();
}
return in_array(strtolower($functionname), $get_defined_functions['internal']);
}
return function_exists($functionname);
}
function version_compare_replacement_sub($version1, $version2, $operator='') {
// If you specify the third optional operator argument, you can test for a particular relationship.
// The possible operators are: <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne respectively.
// Using this argument, the function will return 1 if the relationship is the one specified by the operator, 0 otherwise.
// If a part contains special version strings these are handled in the following order: dev < (alpha = a) < (beta = b) < RC < pl
static $versiontype_lookup = array();
if (empty($versiontype_lookup)) {
$versiontype_lookup['dev'] = 10001;
$versiontype_lookup['a'] = 10002;
$versiontype_lookup['alpha'] = 10002;
$versiontype_lookup['b'] = 10003;
$versiontype_lookup['beta'] = 10003;
$versiontype_lookup['RC'] = 10004;
$versiontype_lookup['pl'] = 10005;
}
if (isset($versiontype_lookup[$version1])) {
$version1 = $versiontype_lookup[$version1];
}
if (isset($versiontype_lookup[$version2])) {
$version2 = $versiontype_lookup[$version2];
}
switch ($operator) {
case '<':
case 'lt':
return intval($version1 < $version2);
break;
case '<=':
case 'le':
return intval($version1 <= $version2);
break;
case '>':
case 'gt':
return intval($version1 > $version2);
break;
case '>=':
case 'ge':
return intval($version1 >= $version2);
break;
case '==':
case '=':
case 'eq':
return intval($version1 == $version2);
break;
case '!=':
case '<>':
case 'ne':
return intval($version1 != $version2);
break;
}
if ($version1 == $version2) {
return 0;
} elseif ($version1 < $version2) {
return -1;
}
return 1;
}
function version_compare_replacement($version1, $version2, $operator='') {
if (function_exists('version_compare')) {
// built into PHP v4.1.0+
return version_compare($version1, $version2, $operator);
}
// The function first replaces _, - and + with a dot . in the version strings
$version1 = strtr($version1, '_-+', '...');
$version2 = strtr($version2, '_-+', '...');
// and also inserts dots . before and after any non number so that for example '4.3.2RC1' becomes '4.3.2.RC.1'.
// Then it splits the results like if you were using explode('.',$ver). Then it compares the parts starting from left to right.
$version1 = eregi_replace('([0-9]+)([A-Z]+)([0-9]+)', '\\1.\\2.\\3', $version1);
$version2 = eregi_replace('([0-9]+)([A-Z]+)([0-9]+)', '\\1.\\2.\\3', $version2);
$parts1 = explode('.', $version1);
$parts2 = explode('.', $version1);
$parts_count = max(count($parts1), count($parts2));
for ($i = 0; $i < $parts_count; $i++) {
$comparison = phpthumb_functions::version_compare_replacement_sub($version1, $version2, $operator);
if ($comparison != 0) {
return $comparison;
}
}
return 0;
}
function phpinfo_array() {
static $phpinfo_array = array();
if (empty($phpinfo_array)) {
ob_start();
phpinfo();
$phpinfo = ob_get_contents();
ob_end_clean();
$phpinfo_array = explode("\n", $phpinfo);
}
return $phpinfo_array;
}
function exif_info() {
static $exif_info = array();
if (empty($exif_info)) {
// based on code by johnschaefer at gmx dot de
// from PHP help on gd_info()
$exif_info = array(
'EXIF Support' => '',
'EXIF Version' => '',
'Supported EXIF Version' => '',
'Supported filetypes' => ''
);
$phpinfo_array = phpthumb_functions::phpinfo_array();
foreach ($phpinfo_array as $dummy => $line) {
$line = trim(strip_tags($line));
foreach ($exif_info as $key => $value) {
if (strpos($line, $key) === 0) {
$newvalue = trim(str_replace($key, '', $line));
$exif_info[$key] = $newvalue;
}
}
}
}
return $exif_info;
}
function ImageTypeToMIMEtype($imagetype) {
if (function_exists('image_type_to_mime_type') && ($imagetype >= 1) && ($imagetype <= 16)) {
// PHP v4.3.0+
return image_type_to_mime_type($imagetype);
}
static $image_type_to_mime_type = array(
1 => 'image/gif', // IMAGETYPE_GIF
2 => 'image/jpeg', // IMAGETYPE_JPEG
3 => 'image/png', // IMAGETYPE_PNG
4 => 'application/x-shockwave-flash', // IMAGETYPE_SWF
5 => 'image/psd', // IMAGETYPE_PSD
6 => 'image/bmp', // IMAGETYPE_BMP
7 => 'image/tiff', // IMAGETYPE_TIFF_II (intel byte order)
8 => 'image/tiff', // IMAGETYPE_TIFF_MM (motorola byte order)
9 => 'application/octet-stream', // IMAGETYPE_JPC
10 => 'image/jp2', // IMAGETYPE_JP2
11 => 'application/octet-stream', // IMAGETYPE_JPX
12 => 'application/octet-stream', // IMAGETYPE_JB2
13 => 'application/x-shockwave-flash', // IMAGETYPE_SWC
14 => 'image/iff', // IMAGETYPE_IFF
15 => 'image/vnd.wap.wbmp', // IMAGETYPE_WBMP
16 => 'image/xbm', // IMAGETYPE_XBM
'gif' => 'image/gif', // IMAGETYPE_GIF
'jpg' => 'image/jpeg', // IMAGETYPE_JPEG
'jpeg' => 'image/jpeg', // IMAGETYPE_JPEG
'png' => 'image/png', // IMAGETYPE_PNG
'bmp' => 'image/bmp', // IMAGETYPE_BMP
'ico' => 'image/x-icon',
);
return (isset($image_type_to_mime_type[$imagetype]) ? $image_type_to_mime_type[$imagetype] : false);
}
function HexCharDisplay($string) {
$len = strlen($string);
$output = '';
for ($i = 0; $i < $len; $i++) {
$output .= ' 0x'.str_pad(dechex(ord($string{$i})), 2, '0', STR_PAD_LEFT);
}
return $output;
}
function IsHexColor($HexColorString) {
return eregi('^[0-9A-F]{6}$', $HexColorString);
}
function ImageColorAllocateAlphaSafe(&$gdimg_hexcolorallocate, $R, $G, $B, $alpha=false) {
if (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.2', '>=') && ($alpha !== false)) {
return ImageColorAllocateAlpha($gdimg_hexcolorallocate, $R, $G, $B, intval($alpha));
} else {
return ImageColorAllocate($gdimg_hexcolorallocate, $R, $G, $B);
}
}
function ImageHexColorAllocate(&$gdimg_hexcolorallocate, $HexColorString, $dieOnInvalid=false, $alpha=false) {
if (!is_resource($gdimg_hexcolorallocate)) {
die('$gdimg_hexcolorallocate is not a GD resource in ImageHexColorAllocate()');
}
if (phpthumb_functions::IsHexColor($HexColorString)) {
$R = hexdec(substr($HexColorString, 0, 2));
$G = hexdec(substr($HexColorString, 2, 2));
$B = hexdec(substr($HexColorString, 4, 2));
return phpthumb_functions::ImageColorAllocateAlphaSafe($gdimg_hexcolorallocate, $R, $G, $B, $alpha);
}
if ($dieOnInvalid) {
die('Invalid hex color string: "'.$HexColorString.'"');
}
return ImageColorAllocate($gdimg_hexcolorallocate, 0x00, 0x00, 0x00);
}
function HexColorXOR($hexcolor) {
return strtoupper(str_pad(dechex(~hexdec($hexcolor) & 0xFFFFFF), 6, '0', STR_PAD_LEFT));
}
function GetPixelColor(&$img, $x, $y) {
if (!is_resource($img)) {
return false;
}
return @ImageColorsForIndex($img, @ImageColorAt($img, $x, $y));
}
function GrayscaleValue($r, $g, $b) {
return round(($r * 0.30) + ($g * 0.59) + ($b * 0.11));
}
function GrayscalePixel($OriginalPixel) {
$gray = phpthumb_functions::GrayscaleValue($OriginalPixel['red'], $OriginalPixel['green'], $OriginalPixel['blue']);
return array('red'=>$gray, 'green'=>$gray, 'blue'=>$gray);
}
function GrayscalePixelRGB($rgb) {
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
return ($r * 0.299) + ($g * 0.587) + ($b * 0.114);
}
function ImageCopyResampleBicubic($dst_img, $src_img, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) {
// ron at korving dot demon dot nl
// http://www.php.net/imagecopyresampled
$scaleX = ($src_w - 1) / $dst_w;
$scaleY = ($src_h - 1) / $dst_h;
$scaleX2 = $scaleX / 2.0;
$scaleY2 = $scaleY / 2.0;
$isTrueColor = ImageIsTrueColor($src_img);
for ($y = $src_y; $y < $src_y + $dst_h; $y++) {
$sY = $y * $scaleY;
$siY = (int) $sY;
$siY2 = (int) $sY + $scaleY2;
for ($x = $src_x; $x < $src_x + $dst_w; $x++) {
$sX = $x * $scaleX;
$siX = (int) $sX;
$siX2 = (int) $sX + $scaleX2;
if ($isTrueColor) {
$c1 = ImageColorAt($src_img, $siX, $siY2);
$c2 = ImageColorAt($src_img, $siX, $siY);
$c3 = ImageColorAt($src_img, $siX2, $siY2);
$c4 = ImageColorAt($src_img, $siX2, $siY);
$r = (( $c1 + $c2 + $c3 + $c4 ) >> 2) & 0xFF0000;
$g = ((($c1 & 0x00FF00) + ($c2 & 0x00FF00) + ($c3 & 0x00FF00) + ($c4 & 0x00FF00)) >> 2) & 0x00FF00;
$b = ((($c1 & 0x0000FF) + ($c2 & 0x0000FF) + ($c3 & 0x0000FF) + ($c4 & 0x0000FF)) >> 2);
} else {
$c1 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $siX, $siY2));
$c2 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $siX, $siY));
$c3 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $siX2, $siY2));
$c4 = ImageColorsForIndex($src_img, ImageColorAt($src_img, $siX2, $siY));
$r = ($c1['red'] + $c2['red'] + $c3['red'] + $c4['red'] ) << 14;
$g = ($c1['green'] + $c2['green'] + $c3['green'] + $c4['green']) << 6;
$b = ($c1['blue'] + $c2['blue'] + $c3['blue'] + $c4['blue'] ) >> 2;
}
ImageSetPixel($dst_img, $dst_x + $x - $src_x, $dst_y + $y - $src_y, $r+$g+$b);
}
}
return true;
}
function ImageCreateFunction($x_size, $y_size) {
$ImageCreateFunction = 'ImageCreate';
if (phpthumb_functions::gd_version() >= 2.0) {
$ImageCreateFunction = 'ImageCreateTrueColor';
}
if (!function_exists($ImageCreateFunction)) {
return phpthumb::ErrorImage($ImageCreateFunction.'() does not exist - no GD support?');
}
if (($x_size <= 0) || ($y_size <= 0)) {
return phpthumb::ErrorImage('Invalid image dimensions: '.$ImageCreateFunction.'('.$x_size.', '.$y_size.')');
}
return $ImageCreateFunction($x_size, $y_size);
}
function ImageCopyRespectAlpha(&$dst_im, &$src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct=100) {
for ($x = $src_x; $x < $src_w; $x++) {
for ($y = $src_y; $y < $src_h; $y++) {
$RealPixel = phpthumb_functions::GetPixelColor($dst_im, $dst_x + $x, $dst_y + $y);
$OverlayPixel = phpthumb_functions::GetPixelColor($src_im, $x, $y);
$alphapct = $OverlayPixel['alpha'] / 127;
$opacipct = $pct / 100;
$overlaypct = (1 - $alphapct) * $opacipct;
$newcolor = phpthumb_functions::ImageColorAllocateAlphaSafe(
$dst_im,
round($RealPixel['red'] * (1 - $overlaypct)) + ($OverlayPixel['red'] * $overlaypct),
round($RealPixel['green'] * (1 - $overlaypct)) + ($OverlayPixel['green'] * $overlaypct),
round($RealPixel['blue'] * (1 - $overlaypct)) + ($OverlayPixel['blue'] * $overlaypct),
//$RealPixel['alpha']);
0);
ImageSetPixel($dst_im, $dst_x + $x, $dst_y + $y, $newcolor);
}
}
return true;
}
function ProportionalResize($old_width, $old_height, $new_width=false, $new_height=false) {
$old_aspect_ratio = $old_width / $old_height;
if (($new_width === false) && ($new_height === false)) {
return false;
} elseif ($new_width === false) {
$new_width = $new_height * $old_aspect_ratio;
} elseif ($new_height === false) {
$new_height = $new_width / $old_aspect_ratio;
}
$new_aspect_ratio = $new_width / $new_height;
if ($new_aspect_ratio == $old_aspect_ratio) {
// great, done
} elseif ($new_aspect_ratio < $old_aspect_ratio) {
// limited by width
$new_height = $new_width / $old_aspect_ratio;
} elseif ($new_aspect_ratio > $old_aspect_ratio) {
// limited by height
$new_width = $new_height * $old_aspect_ratio;
}
return array(round($new_width), round($new_height));
}
function SafeExec($command) {
static $AllowedExecFunctions = array();
if (empty($AllowedExecFunctions)) {
$AllowedExecFunctions = array('shell_exec'=>true, 'passthru'=>true, 'system'=>true, 'exec'=>true);
if (@ini_get('safe_mode')) {
$AllowedExecFunctions['shell_exec'] = false;
}
$disable_functions = explode(',', @ini_get('disable_functions'));
foreach ($AllowedExecFunctions as $key => $value) {
if (in_array($key, $disable_functions)) {
$AllowedExecFunctions[$key] = false;
}
}
}
foreach ($AllowedExecFunctions as $execfunction => $is_allowed) {
if (!$is_allowed) {
continue;
}
if ($execfunction == 'passthru') {
ob_start();
$execfunction($command);
$returnvalue = ob_get_contents();
ob_end_clean();
} else {
$returnvalue = @$execfunction($command);
}
return $returnvalue;
}
return false;
}
function ApacheLookupURIarray($filename) {
// apache_lookup_uri() only works when PHP is installed as an Apache module.
if (php_sapi_name() == 'apache') {
$keys = array('status', 'the_request', 'status_line', 'method', 'content_type', 'handler', 'uri', 'filename', 'path_info', 'args', 'boundary', 'no_cache', 'no_local_copy', 'allowed', 'send_bodyct', 'bytes_sent', 'byterange', 'clength', 'unparsed_uri', 'mtime', 'request_time');
if ($apacheLookupURIobject = @apache_lookup_uri($filename)) {
$apacheLookupURIarray = array();
foreach ($keys as $dummy => $key) {
$apacheLookupURIarray[$key] = @$apacheLookupURIobject->$key;
}
return $apacheLookupURIarray;
}
}
return false;
}
function gd_is_bundled() {
static $isbundled = null;
if (is_null($isbundled)) {
$gd_info = gd_info();
$isbundled = (strpos($gd_info['GD Version'], 'bundled') !== false);
}
return $isbundled;
}
function gd_version($fullstring=false) {
static $cache_gd_version = array();
if (empty($cache_gd_version)) {
$gd_info = gd_info();
if (eregi('bundled \((.+)\)$', $gd_info['GD Version'], $matches)) {
$cache_gd_version[1] = $gd_info['GD Version']; // e.g. "bundled (2.0.15 compatible)"
$cache_gd_version[0] = (float) $matches[1]; // e.g. "2.0" (not "bundled (2.0.15 compatible)")
} else {
$cache_gd_version[1] = $gd_info['GD Version']; // e.g. "1.6.2 or higher"
$cache_gd_version[0] = (float) substr($gd_info['GD Version'], 0, 3); // e.g. "1.6" (not "1.6.2 or higher")
}
}
return $cache_gd_version[intval($fullstring)];
}
function gd_ImageSaveAlpha(&$img, $flag) {
// requires PHP >= 4.3.2
// requires GD >= 2.0.1
if (function_exists('ImageSaveAlpha')) {
return ImageSaveAlpha($img, $flag);
}
return false;
}
function filesize_remote($remotefile, $timeout=10) {
$size = false;
$url = parse_url($remotefile);
if ($fp = @fsockopen($url['host'], ($url['port'] ? $url['port'] : 80), $errno, $errstr, $timeout)) {
fwrite($fp, 'HEAD '.@$url['path'].@$url['query'].' HTTP/1.0'."\r\n".'Host: '.@$url['host']."\r\n\r\n");
if (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.0', '>=')) {
stream_set_timeout($fp, $timeout);
}
while (!feof($fp)) {
$headerline = fgets($fp, 4096);
if (eregi('^Content-Length: (.*)', $headerline, $matches)) {
$size = intval($matches[1]);
break;
}
}
fclose ($fp);
}
return $size;
}
function filedate_remote($remotefile, $timeout=10) {
$date = false;
$url = parse_url($remotefile);
if ($fp = @fsockopen($url['host'], ($url['port'] ? $url['port'] : 80), $errno, $errstr, $timeout)) {
fwrite($fp, 'HEAD '.@$url['path'].@$url['query'].' HTTP/1.0'."\r\n".'Host: '.@$url['host']."\r\n\r\n");
if (phpthumb_functions::version_compare_replacement(phpversion(), '4.3.0', '>=')) {
stream_set_timeout($fp, $timeout);
}
while (!feof($fp)) {
$headerline = fgets($fp, 4096);
if (eregi('^Last-Modified: (.*)', $headerline, $matches)) {
$date = strtotime($matches[1]) - date('Z');
break;
}
}
fclose ($fp);
}
return $date;
}
function md5_file_safe($filename) {
// md5_file() doesn't exist in PHP < 4.2.0
if (function_exists('md5_file')) {
return md5_file($filename);
}
if ($fp = @fopen($filename, 'rb')) {
$filedata = fread($fp, filesize($filename));
fclose($fp);
return md5($filedata);
}
return false;
}
function nonempty_min() {
$arg_list = func_get_args();
$acceptable = array();
foreach ($arg_list as $dummy => $arg) {
if ($arg) {
$acceptable[] = $arg;
}
}
return min($acceptable);
}
function LittleEndian2String($number, $minbytes=1) {
$intstring = '';
while ($number > 0) {
$intstring = $intstring.chr($number & 255);
$number >>= 8;
}
return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);
}
function OneOfThese() {
// return the first useful (non-empty/non-zero/non-false) value from those passed
$arg_list = func_get_args();
foreach ($arg_list as $key => $value) {
if ($value) {
return $value;
}
}
return false;
}
function SafeURLread($url, &$error) {
if (function_exists('curl_version')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
$rawData = curl_exec($ch);
curl_close($ch);
if (strlen($rawData) > 0) {
return $rawData;
}
$error .= 'CURL available but returned no data; ';
} else {
$error .= 'CURL unavailable; ';
}
if (@ini_get('allow_url_fopen')) {
$rawData = '';
ob_start();
if ($fp = fopen($url, 'rb')) {
do {
$buffer = fread($fp, 8192);
$rawData .= $buffer;
} while (strlen($buffer) > 0);
fclose($fp);
} else {
$error = trim(strip_tags(ob_get_contents()));
}
ob_end_clean();
if (!$error) {
return $rawData;
}
$error .= '; "allow_url_fopen" enabled but returned no data; ';
} else {
$error .= '"allow_url_fopen" disabled; ';
}
return false;
}
}
if (!function_exists('gd_info')) {
// built into PHP v4.3.0+ (with bundled GD2 library)
function gd_info() {
static $gd_info = array();
if (empty($gd_info)) {
// based on code by johnschaefer at gmx dot de
// from PHP help on gd_info()
$gd_info = array(
'GD Version' => '',
'FreeType Support' => false,
'FreeType Linkage' => '',
'T1Lib Support' => false,
'GIF Read Support' => false,
'GIF Create Support' => false,
'JPG Support' => false,
'PNG Support' => false,
'WBMP Support' => false,
'XBM Support' => false
);
$phpinfo_array = phpthumb_functions::phpinfo_array();
foreach ($phpinfo_array as $dummy => $line) {
$line = trim(strip_tags($line));
foreach ($gd_info as $key => $value) {
//if (strpos($line, $key) !== false) {
if (strpos($line, $key) === 0) {
$newvalue = trim(str_replace($key, '', $line));
$gd_info[$key] = $newvalue;
}
}
}
if (empty($gd_info['GD Version'])) {
// probable cause: "phpinfo() disabled for security reasons"
if (function_exists('ImageTypes')) {
$imagetypes = ImageTypes();
if ($imagetypes & IMG_PNG) {
$gd_info['PNG Support'] = true;
}
if ($imagetypes & IMG_GIF) {
$gd_info['GIF Create Support'] = true;
}
if ($imagetypes & IMG_JPG) {
$gd_info['JPG Support'] = true;
}
if ($imagetypes & IMG_WBMP) {
$gd_info['WBMP Support'] = true;
}
}
// to determine capability of GIF creation, try to use ImageCreateFromGIF on a 1px GIF
if (function_exists('ImageCreateFromGIF')) {
if ($tempfilename = phpthumb::phpThumb_tempnam()) {
if ($fp_tempfile = @fopen($tempfilename, 'wb')) {
fwrite($fp_tempfile, base64_decode('R0lGODlhAQABAIAAAH//AP///ywAAAAAAQABAAACAUQAOw==')); // very simple 1px GIF file base64-encoded as string
fclose($fp_tempfile);
// if we can convert the GIF file to a GD image then GIF create support must be enabled, otherwise it's not
$gd_info['GIF Read Support'] = (bool) @ImageCreateFromGIF($tempfilename);
}
unlink($tempfilename);
}
}
if (function_exists('ImageCreateTrueColor') && @ImageCreateTrueColor(1, 1)) {
$gd_info['GD Version'] = '2.0.1 or higher (assumed)';
} elseif (function_exists('ImageCreate') && @ImageCreate(1, 1)) {
$gd_info['GD Version'] = '1.6.0 or higher (assumed)';
}
}
}
return $gd_info;
}
}
if (!function_exists('is_executable')) {
// in PHP v3+, but v5.0+ for Windows
function is_executable($filename) {
// poor substitute, but better than nothing
return file_exists($filename);
}
}
if (!function_exists('file_get_contents')) {
// included in PHP v4.3.0+
function file_get_contents($filename) {
if (eregi('^(f|ht)tp\://', $filename)) {
return SafeURLread($filename);
}
if ($fp = @fopen($filename, 'rb')) {
$buffer = fread($fp, filesize($filename));
fclose($fp);
return $buffer;
}
return false;
}
}
if (!function_exists('file_put_contents')) {
// included in PHP v5.0.0+
function file_put_contents($filename, $filedata) {
if ($fp = @fopen($filename, 'wb')) {
fwrite($fp, $filedata);
fclose($fp);
return true;
}
return false;
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,119 @@
<?php
//////////////////////////////////////////////////////////////
/// phpThumb() by James Heinrich <info@silisoftware.com> //
// available at http://phpthumb.sourceforge.net ///
//////////////////////////////////////////////////////////////
/// //
// phpthumb.ico.php - .ICO output format functions //
// ///
//////////////////////////////////////////////////////////////
class phpthumb_ico {
function phpthumb_ico() {
return true;
}
function GD2ICOstring(&$gd_image_array) {
foreach ($gd_image_array as $key => $gd_image) {
$ImageWidths[$key] = ImageSX($gd_image);
$ImageHeights[$key] = ImageSY($gd_image);
$bpp[$key] = ImageIsTrueColor($gd_image) ? 32 : 24;
$totalcolors[$key] = ImageColorsTotal($gd_image);
$icXOR[$key] = '';
for ($y = $ImageHeights[$key] - 1; $y >= 0; $y--) {
for ($x = 0; $x < $ImageWidths[$key]; $x++) {
$argb = phpthumb_functions::GetPixelColor($gd_image, $x, $y);
$a = round(255 * ((127 - $argb['alpha']) / 127));
$r = $argb['red'];
$g = $argb['green'];
$b = $argb['blue'];
if ($bpp[$key] == 32) {
$icXOR[$key] .= chr($b).chr($g).chr($r).chr($a);
} elseif ($bpp[$key] == 24) {
$icXOR[$key] .= chr($b).chr($g).chr($r);
}
if ($a < 128) {
@$icANDmask[$key][$y] .= '1';
} else {
@$icANDmask[$key][$y] .= '0';
}
}
// mask bits are 32-bit aligned per scanline
while (strlen($icANDmask[$key][$y]) % 32) {
$icANDmask[$key][$y] .= '0';
}
}
$icAND[$key] = '';
foreach ($icANDmask[$key] as $y => $scanlinemaskbits) {
for ($i = 0; $i < strlen($scanlinemaskbits); $i += 8) {
$icAND[$key] .= chr(bindec(str_pad(substr($scanlinemaskbits, $i, 8), 8, '0', STR_PAD_LEFT)));
}
}
}
foreach ($gd_image_array as $key => $gd_image) {
$biSizeImage = $ImageWidths[$key] * $ImageHeights[$key] * ($bpp[$key] / 8);
// BITMAPINFOHEADER - 40 bytes
$BitmapInfoHeader[$key] = '';
$BitmapInfoHeader[$key] .= "\x28\x00\x00\x00"; // DWORD biSize;
$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageWidths[$key], 4); // LONG biWidth;
// The biHeight member specifies the combined
// height of the XOR and AND masks.
$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($ImageHeights[$key] * 2, 4); // LONG biHeight;
$BitmapInfoHeader[$key] .= "\x01\x00"; // WORD biPlanes;
$BitmapInfoHeader[$key] .= chr($bpp[$key])."\x00"; // wBitCount;
$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // DWORD biCompression;
$BitmapInfoHeader[$key] .= phpthumb_functions::LittleEndian2String($biSizeImage, 4); // DWORD biSizeImage;
$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // LONG biXPelsPerMeter;
$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // LONG biYPelsPerMeter;
$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // DWORD biClrUsed;
$BitmapInfoHeader[$key] .= "\x00\x00\x00\x00"; // DWORD biClrImportant;
}
$icondata = "\x00\x00"; // idReserved; // Reserved (must be 0)
$icondata .= "\x01\x00"; // idType; // Resource Type (1 for icons)
$icondata .= phpthumb_functions::LittleEndian2String(count($gd_image_array), 2); // idCount; // How many images?
$dwImageOffset = 6 + (count($gd_image_array) * 16);
foreach ($gd_image_array as $key => $gd_image) {
// ICONDIRENTRY idEntries[1]; // An entry for each image (idCount of 'em)
$icondata .= chr($ImageWidths[$key]); // bWidth; // Width, in pixels, of the image
$icondata .= chr($ImageHeights[$key]); // bHeight; // Height, in pixels, of the image
$icondata .= chr($totalcolors[$key]); // bColorCount; // Number of colors in image (0 if >=8bpp)
$icondata .= "\x00"; // bReserved; // Reserved ( must be 0)
$icondata .= "\x01\x00"; // wPlanes; // Color Planes
$icondata .= chr($bpp[$key])."\x00"; // wBitCount; // Bits per pixel
$dwBytesInRes = 40 + strlen($icXOR[$key]) + strlen($icAND[$key]);
$icondata .= phpthumb_functions::LittleEndian2String($dwBytesInRes, 4); // dwBytesInRes; // How many bytes in this resource?
$icondata .= phpthumb_functions::LittleEndian2String($dwImageOffset, 4); // dwImageOffset; // Where in the file is this image?
$dwImageOffset += strlen($BitmapInfoHeader[$key]);
$dwImageOffset += strlen($icXOR[$key]);
$dwImageOffset += strlen($icAND[$key]);
}
foreach ($gd_image_array as $key => $gd_image) {
$icondata .= $BitmapInfoHeader[$key];
$icondata .= $icXOR[$key];
$icondata .= $icAND[$key];
}
return $icondata;
}
}
?>

View File

@ -0,0 +1,162 @@
<?php
//////////////////////////////////////////////////////////////
//// ////
//// p h p U n s h a r p M a s k ////
//// ////
//// Unsharp mask algorithm by Torstein H<>nsi 2003. ////
//// thoensi_at_netcom_dot_no ////
//// Please leave this notice. ////
//// ////
//////////////////////////////////////////////////////////////
/// From: http://vikjavev.no/hovudsida/umtestside.php //
// //
// Reformatted by James Heinrich <info@silisoftware.com> //
// for use in phpThumb() on 3 February 2003. //
// //
// phpThumb() is found at http://phpthumb.sourceforge.net ///
//////////////////////////////////////////////////////////////
/*
WARNING! Due to a known bug in PHP 4.3.2 this script is not working well in this version.
The sharpened images get too dark. The bug is fixed in version 4.3.3.
Unsharp masking is a traditional darkroom technique that has proven very suitable for
digital imaging. The principle of unsharp masking is to create a blurred copy of the image
and compare it to the underlying original. The difference in colour values
between the two images is greatest for the pixels near sharp edges. When this
difference is subtracted from the original image, the edges will be
accentuated.
The Amount parameter simply says how much of the effect you want. 100 is 'normal'.
Radius is the radius of the blurring circle of the mask. 'Threshold' is the least
difference in colour values that is allowed between the original and the mask. In practice
this means that low-contrast areas of the picture are left unrendered whereas edges
are treated normally. This is good for pictures of e.g. skin or blue skies.
Any suggenstions for improvement of the algorithm, expecially regarding the speed
and the roundoff errors in the Gaussian blur process, are welcome.
*/
class phpUnsharpMask {
function applyUnsharpMask(&$img, $amount, $radius, $threshold) {
// $img is an image that is already created within php using
// imgcreatetruecolor. No url! $img must be a truecolor image.
// Attempt to calibrate the parameters to Photoshop:
$amount = min($amount, 500);
$amount = $amount * 0.016;
if ($amount == 0) {
return true;
}
$radius = min($radius, 50);
$radius = $radius * 2;
$threshold = min($threshold, 255);
$radius = abs(round($radius)); // Only integers make sense.
if ($radius == 0) {
return true;
}
$w = ImageSX($img);
$h = ImageSY($img);
$imgCanvas = ImageCreateTrueColor($w, $h);
$imgCanvas2 = ImageCreateTrueColor($w, $h);
ImageCopy($imgCanvas, $img, 0, 0, 0, 0, $w, $h);
ImageCopy($imgCanvas2, $img, 0, 0, 0, 0, $w, $h);
$builtinFilterSucceeded = false;
if ($radius == 1) {
if (phpthumb_functions::version_compare_replacement(phpversion(), '5.0.0', '>=') && phpthumb_functions::gd_is_bundled()) {
if (ImageFilter($imgCanvas, IMG_FILTER_GAUSSIAN_BLUR) && ImageFilter($imgCanvas2, IMG_FILTER_GAUSSIAN_BLUR)) {
$builtinFilterSucceeded = true;
}
}
}
if (!$builtinFilterSucceeded) {
$imgBlur = ImageCreateTrueColor($w, $h);
$imgBlur2 = ImageCreateTrueColor($w, $h);
///////////////////////////
//
// Gaussian blur matrix:
// 1 2 1
// 2 4 2
// 1 2 1
//
///////////////////////////
// Move copies of the image around one pixel at the time and merge them with weight
// according to the matrix. The same matrix is simply repeated for higher radii.
for ($i = 0; $i < $radius; $i++) {
ImageCopy ($imgBlur, $imgCanvas, 0, 0, 1, 1, $w - 1, $h - 1); // up left
ImageCopyMerge($imgBlur, $imgCanvas, 1, 1, 0, 0, $w, $h, 50); // down right
ImageCopyMerge($imgBlur, $imgCanvas, 0, 1, 1, 0, $w - 1, $h, 33.33333); // down left
ImageCopyMerge($imgBlur, $imgCanvas, 1, 0, 0, 1, $w, $h - 1, 25); // up right
ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 1, 0, $w - 1, $h, 33.33333); // left
ImageCopyMerge($imgBlur, $imgCanvas, 1, 0, 0, 0, $w, $h, 25); // right
ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 0, 1, $w, $h - 1, 20 ); // up
ImageCopyMerge($imgBlur, $imgCanvas, 0, 1, 0, 0, $w, $h, 16.666667); // down
ImageCopyMerge($imgBlur, $imgCanvas, 0, 0, 0, 0, $w, $h, 50); // center
ImageCopy ($imgCanvas, $imgBlur, 0, 0, 0, 0, $w, $h);
// During the loop above the blurred copy darkens, possibly due to a roundoff
// error. Therefore the sharp picture has to go through the same loop to
// produce a similar image for comparison. This is not a good thing, as processing
// time increases heavily.
ImageCopy ($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 33.33333);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 25);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 20 );
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 16.666667);
ImageCopyMerge($imgBlur2, $imgCanvas2, 0, 0, 0, 0, $w, $h, 50);
ImageCopy ($imgCanvas2, $imgBlur2, 0, 0, 0, 0, $w, $h);
}
ImageDestroy($imgBlur);
ImageDestroy($imgBlur2);
}
// Calculate the difference between the blurred pixels and the original
// and set the pixels
for ($x = 0; $x < $w; $x++) { // each row
for ($y = 0; $y < $h; $y++) { // each pixel
$rgbOrig = ImageColorAt($imgCanvas2, $x, $y);
$rOrig = (($rgbOrig >> 16) & 0xFF);
$gOrig = (($rgbOrig >> 8) & 0xFF);
$bOrig = ($rgbOrig & 0xFF);
$rgbBlur = ImageColorAt($imgCanvas, $x, $y);
$rBlur = (($rgbBlur >> 16) & 0xFF);
$gBlur = (($rgbBlur >> 8) & 0xFF);
$bBlur = ($rgbBlur & 0xFF);
// When the masked pixels differ less from the original
// than the threshold specifies, they are set to their original value.
$rNew = (abs($rOrig - $rBlur) >= $threshold) ? max(0, min(255, ($amount * ($rOrig - $rBlur)) + $rOrig)) : $rOrig;
$gNew = (abs($gOrig - $gBlur) >= $threshold) ? max(0, min(255, ($amount * ($gOrig - $gBlur)) + $gOrig)) : $gOrig;
$bNew = (abs($bOrig - $bBlur) >= $threshold) ? max(0, min(255, ($amount * ($bOrig - $bBlur)) + $bOrig)) : $bOrig;
if (($rOrig != $rNew) || ($gOrig != $gNew) || ($bOrig != $bNew)) {
$pixCol = ImageColorAllocate($img, $rNew, $gNew, $bNew);
ImageSetPixel($img, $x, $y, $pixCol);
}
}
}
ImageDestroy($imgCanvas);
ImageDestroy($imgCanvas2);
return true;
}
}
?>

View File

@ -0,0 +1,19 @@
<?php
require_once("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,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_RunshopsRating` (`runshop_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_RunshopsRatingCategory` 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_RunshopsRating` WHERE `category_id_fk`='{$varItem}' AND `runshop_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_RunshopsRating` WHERE `runshop_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_RunshopsRating` WHERE `category_id_fk`='{$varItem}' AND `runshop_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,86 @@
<?PHP
include("config.php");
require_once("rating/classes/include.all.php");
include("rating/int.to.words.php");
if (!isset($_GET['region']) || !is_numeric($_GET['region'])) {
header('Location: '.$site_url.'/?error=no_region');
}
$results = mysql_query("SELECT regionlong FROM ".$prefix."ResourceRegions WHERE regionid = '".mysql_real_escape_string($_GET[region])."' LIMIT 1");
$row = mysql_fetch_array($results);
$selected_item = mysql_real_escape_string($_GET[region]);
$regionname = $row[regionlong];
$results = mysql_query("SELECT gr.runshop_id, gr.runshop_name, gr.runshop_address, gr.runshop_address_two, gr.runshop_city, gr.runshop_state, gr.runshop_zip, gr.runshop_phone, gr.runshop_fax, gr.runshop_email, gr.runshop_website, gr.runshop_cart
FROM ".$prefix."Runshops AS gr
RIGHT JOIN ".$prefix."ResourceStates AS gts
ON gts.regionid = '".mysql_real_escape_string($_GET[region])."' AND gr.runshop_state_tag = gts.statetag
WHERE gr.runshop_valid = 1 ORDER BY gr.runshop_name ASC");
$none = FALSE;
if (mysql_num_rows($results) == 0) {
$none = TRUE;
}
// set the page title
$pagetitle = $regionname;
// set meta tags
$meta_keywords = "running stores in ".$regionname;
$meta_description = "Trying to find running stores in ".$regionname."? Here is a listing of all ".$regionname." running stores.";
?>
<? 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 clearfix">
<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">Running Stores</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 Retailer</a>
<? } ?>
<hr class="line" />
<? include("include_region_list.php"); ?>
<h2><? echo $regionname ?> Region</h2>
<hr />
<? if($none == TRUE) {
echo "<p>No running stores 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>

326
site/runshops/search.php Normal file
View File

@ -0,0 +1,326 @@
<?PHP include("config.php");
// set the page title
$pagetitle = "Search The Database";
// set meta tags
$meta_keywords = "search running stores";
$meta_description = "Do you want to search for shops in our online running store 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."ResourceStates");
?>
<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 Running Store</h1>
<p>If you would like to search for a running store, please use the form below. None of the fields are mandatory. Checking no box in a field indicates you don't care if a shop has or does not have a treadmill, or motion capture system, or any of the listed brands. 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>Technology, Community &amp; Education</h3>
</div>
</div>
<div class="drow">
<div class="dcell name">Diagnostic Equipment Used</div>
<div class="dcell divider"></div>
<div class="dcell value">
<table width="100%" cellpadding="2" cellspacing="2"><?
$results = mysql_query("SELECT * FROM ".$prefix."RunshopsDiagnostics ORDER BY diagnostic_name ASC");
$i = 0;
echo("<tr>");
//echo("<input type=\"hidden\" name=\"diagnostics[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
if(!($i%4)) echo "</tr><tr>";
echo("<td width=\"25%\"><input type=\"checkbox\" name=\"diagnostics[]\" value=\"$row[diagnostic_id]\" >$row[diagnostic_name]</td>\n");
$i++;
}
//if(!($i%4)) echo "</tr><tr>";
//echo("<td width=\"25%\"><input type=\"checkbox\" name=\"diagnostics[]\" value=\"999\" ><strong>ANY</strong></td>\n");
echo("</tr>");
?>
</table>
</div>
</div>
<div class="drow">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<h3>Brands</h3>
</div>
</div>
<div class="drow">
<div class="dcell name">eCommerce Online Shopping Cart</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input type="checkbox" name="ecommerce" value="1"> Yes
</div>
</div>
<div class="drow">
<div class="dcell name">Running Shoe Brands</div>
<div class="dcell divider"></div>
<div class="dcell value">
<table width="100%" cellpadding="2" cellspacing="2">
<?
$results = mysql_query("SELECT * FROM ".$prefix."RunshopsShoes ORDER BY shoe_name ASC");
$i = 0;
echo("<tr>");
//echo("<input type=\"hidden\" name=\"shoes[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
if(!($i%4)) echo "</tr><tr>";
echo("<td width=\"25%\"><input type=\"checkbox\" name=\"shoes[]\" value=\"$row[shoe_id]\" >$row[shoe_name]</td>\n");
$i++;
}
//if(!($i%4)) echo "</tr><tr>";
//echo("<td width=\"25%\"><input type=\"checkbox\" name=\"shoes[]\" value=\"999\" ><strong>ANY</strong></td>\n");
echo("</tr>");
?>
</table>
</div>
</div>
<div class="drow">
<div class="dcell name">Sock Brands</div>
<div class="dcell divider"></div>
<div class="dcell value">
<table width="100%" cellpadding="2" cellspacing="2">
<?
$results = mysql_query("SELECT * FROM ".$prefix."RunshopsSocks ORDER BY sock_name ASC");
$i = 0;
echo("<tr>");
//echo("<input type=\"hidden\" name=\"socks[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
if(!($i%4)) echo "</tr><tr>";
echo("<td width=\"25%\"><input type=\"checkbox\" name=\"socks[]\" value=\"$row[sock_id]\" >$row[sock_name]</td>\n");
$i++;
}
//if(!($i%4)) echo "</tr><tr>";
//echo("<td width=\"25%\"><input type=\"checkbox\" name=\"socks[]\" value=\"999\" ><strong>ANY</strong></td>\n");
echo("</tr>");
?>
</table>
</div>
</div>
<div class="drow">
<div class="dcell name">Run Apparel Brands</div>
<div class="dcell divider"></div>
<div class="dcell value">
<table width="100%" cellpadding="2" cellspacing="2">
<?
$results = mysql_query("SELECT * FROM ".$prefix."RunshopsApparelRun ORDER BY apparel_run_name ASC");
$i = 0;
echo("<tr>");
//echo("<input type=\"hidden\" name=\"apparel_run[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
if(!($i%4)) echo "</tr><tr>";
echo("<td width=\"25%\"><input type=\"checkbox\" name=\"apparel_run[]\" value=\"$row[apparel_run_id]\" >$row[apparel_run_name]</td>\n");
$i++;
}
//if(!($i%4)) echo "</tr><tr>";
//echo("<td width=\"25%\"><input type=\"checkbox\" name=\"apparel_run[]\" value=\"999\" ><strong>ANY</strong></td>\n");
echo("</tr>");
?>
</table>
</div>
</div>
<div class="drow">
<div class="dcell name">Tri Apparel Brands</div>
<div class="dcell divider"></div>
<div class="dcell value">
<table width="100%" cellpadding="2" cellspacing="2"><?
$results = mysql_query("SELECT * FROM ".$prefix."RunshopsApparelTri ORDER BY apparel_tri_name ASC");
$i = 0;
echo("<tr>");
//echo("<input type=\"hidden\" name=\"apparel_tri[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
if(!($i%4)) echo "</tr><tr>";
echo("<td width=\"25%\"><input type=\"checkbox\" name=\"apparel_tri[]\" value=\"$row[apparel_tri_id]\" >$row[apparel_tri_name]</td>\n");
$i++;
}
//if(!($i%4)) echo "</tr><tr>";
//echo("<td width=\"25%\"><input type=\"checkbox\" name=\"apparel_tri[]\" value=\"999\" ><strong>ANY</strong></td>\n");
echo("</tr>");
?>
</table>
</div>
</div>
<div class="drow">
<div class="dcell name">Swim Gear</div>
<div class="dcell divider"></div>
<div class="dcell value">
<table width="100%" cellpadding="2" cellspacing="2"><?
$results = mysql_query("SELECT * FROM ".$prefix."ResourceSwimgear ORDER BY swimgear_name ASC");
$i = 0;
echo("<tr>");
//echo("<input type=\"hidden\" name=\"swimgear[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
if(!($i%4)) echo "</tr><tr>";
echo("<td width=\"25%\"><input type=\"checkbox\" name=\"swimgear[]\" value=\"$row[swimgear_id]\" >$row[swimgear_name]</td>\n");
$i++;
}
//if(!($i%4)) echo "</tr><tr>";
//echo("<td width=\"25%\"><input type=\"checkbox\" name=\"swimgear[]\" value=\"0\" >Any</td>\n");
echo("</tr>");
?>
</table>
</div>
</div>
<div class="drow">
<div class="dcell name">Wetsuits</div>
<div class="dcell divider"></div>
<div class="dcell value">
<table width="100%" cellpadding="2" cellspacing="2"><?
$results = mysql_query("SELECT * FROM ".$prefix."ResourceWetsuits ORDER BY wetsuit_name ASC");
$i = 0;
echo("<tr>");
//echo("<input type=\"hidden\" name=\"wetsuits[]\" value=\"0\" >");
while ($row = mysql_fetch_array($results)) {
if(!($i%4)) echo "</tr><tr>";
echo("<td width=\"25%\"><input type=\"checkbox\" name=\"wetsuits[]\" value=\"$row[wetsuit_id]\" >$row[wetsuit_name]</td>\n");
$i++;
}
//if(!($i%4)) echo "</tr><tr>";
//echo("<td width=\"25%\"><input type=\"checkbox\" name=\"wetsuits[]\" value=\"0\" >Any</td>\n");
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."ResourceStates AS gts
LEFT JOIN ".$prefix."ResourceRegions AS gtr
ON gts.regionid = gtr.regionid
ORDER BY gtr.regionlong";
$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="runshops">
<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>

209
site/runshops/search_X.php Normal file
View File

@ -0,0 +1,209 @@
<?PHP
include("config.php");
require_once("rating/classes/include.all.php");
// string comparison match percent
$comp_pct = 80;
if (!$_POST){ header('Location: '.$site_url); }
// build the SQL query
$sql = "SELECT runshop_id, runshop_name, runshop_address, runshop_address_two, runshop_city, runshop_state, runshop_zip, runshop_phone, runshop_fax, runshop_email, runshop_website, runshop_cart FROM ".$prefix."Runshops WHERE runshop_valid=1 ";
if (isset($_POST[ecommerce])) {
$sql = $sql." AND runshop_cart = 1";
}
if (isset($_POST[wetsuits])) {
foreach ($_POST[wetsuits] AS $value) {
$sql = $sql." AND runshop_wetsuits LIKE '%,$value,%'";
}
}
if (isset($_POST[swimgear])) {
foreach ($_POST[swimgear] AS $value) {
$sql = $sql." AND runshop_swimgear LIKE '%,$value,%'";
}
}
if (isset($_POST[diagnostics])) {
foreach ($_POST[diagnostics] AS $value) {
$sql = $sql." AND runshop_diagnostics LIKE '%,$value,%'";
}
}
if (isset($_POST[shoes])) {
foreach ($_POST[shoes] AS $value) {
$sql = $sql." AND runshop_shoes LIKE '%,$value,%'";
}
}
if (isset($_POST[socks])) {
foreach ($_POST[socks] AS $value) {
$sql = $sql." AND runshop_socks LIKE '%,$value,%'";
}
}
if (isset($_POST[apparel_run])) {
foreach ($_POST[apparel_run] AS $value) {
$sql = $sql." AND runshop_apparel_run LIKE '%,$value,%'";
}
}
if (isset($_POST[apparel_tri])) {
foreach ($_POST[apparel_tri] AS $value) {
$sql = $sql." AND runshop_apparel_tri 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 runshop_state_tag IN $statelist";
}
$sql = $sql." ORDER BY runshop_name ASC";
//echo $sql;
$results = mysql_query($sql);
$none = FALSE;
if (mysql_num_rows($results) == 0) {
$none = TRUE;
}
$match_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_runshopes = mysql_fetch_array($results)) {
// build an array that we can loop through.
$arr_runshopes[$i] = $row_runshopes;
$i++;
}
$arr_Matches = array();
foreach ($arr_runshopes AS $runshop) {
if (stripos($runshop['runshop_name'], $_POST['keyword']) !== false) {
// push this onto the array of matches
$runshop['percent'] = 100;
array_push($arr_Matches, $runshop);
} else {
$name_nospace = str_replace(" ", "", $runshop['runshop_name']);
$keyword_nospace = str_replace(" ", "", $_POST['keyword']);
if (stripos($name_nospace, $keyword_nospace) !== false) {
// push this onto the array of matches
$runshop['percent'] = 90;
array_push($arr_Matches, $runshop);
} else {
// trim redundant keywords
$runshop_name = $runshop['runshop_name'];
foreach ($trim_words AS $word) {
$runshop_name = str_ireplace($word, " ", $runshop_name);
}
//$runshop_name = str_ireplace(" ", "", $runshop_name);
$runshop_name = strtolower($runshop_name);
$arr_runshop_name = explode(" ", $runshop_name);
$_POST['keyword'] = strtolower($_POST['keyword']);
$_POST['keyword'] = str_replace(" ", "", $_POST['keyword']);
foreach ($arr_runshop_name AS $test_word) {
similar_text($test_word, $_POST['keyword'], $percent);
if ($percent >= $comp_pct) {
// push this onto the array of matches
$runshop['percent'] = round($percent, 0);
//$runshop['trimmed'] = $runshop_name;
array_push($arr_Matches, $runshop);
break;
}
}
}
}
}
if (count($arr_Matches) == 0) {
$none = TRUE;
}
$match_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, running stores, triathlon, results";
$meta_description = "Triathlon running stores matching a user's search query. A list of matching running stores.";
?>
<? 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 $match_count; ?></b> Running Stores Match Your Search</p>
<table border="0" cellspacing="0" cellpadding="1" width="580">
<?
if ($bool_Keywords == true) {
foreach($arr_Matches AS $row){
include("include_store.php");
} // end foreach arr_Matches
} else { //if bool_Keywords
while ($row = mysql_fetch_array($results)) {
include("include_store.php");
} // end foreach mysql_fetch_array ?>
<? } // end 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>

129
site/runshops/statelist.php Normal file
View File

@ -0,0 +1,129 @@
<?PHP
include("config.php");
require_once("rating/classes/include.all.php");
include("rating/int.to.words.php");
if (!isset($_GET['state']) || !in_array($_GET['state'], $state_tag_list)) {
header('Location: '.$site_url.'/?error=no_state');
}
$results = mysql_query("SELECT runshop_state FROM ".$prefix."Runshops WHERE runshop_state_tag='".substr(mysql_real_escape_string($_GET[state]),0,20)."' AND runshop_valid = 1 LIMIT 1");
$row = mysql_fetch_array($results);
$statename = $row[runshop_state];
$none = FALSE;
if(mysql_num_rows($results) < 1){
$statename = substr(mysql_real_escape_string($_GET[state]),0,20);
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 runshop_id, runshop_name, runshop_address, runshop_address_two, runshop_city, runshop_state, runshop_zip, runshop_phone, runshop_fax, runshop_email, runshop_website, runshop_cart FROM ".$prefix."Runshops WHERE runshop_state_tag='".substr(mysql_real_escape_string($_GET[state]),0,20)."' AND runshop_valid=1 ORDER BY runshop_name ASC");
// set the page title
$pagetitle = $statename;
$selected_item = substr(mysql_real_escape_string($_GET[state]),0,20);
// set meta tags
$meta_keywords = "running stores in ".$statename;
$meta_description = "Trying to find running stores in ".$statename."? Here is a listing of all ".$statename." running stores. Users can even rate and comment on these running stores.";
?>
<? 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">Running Stores</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 Retailer</a>
<? } ?>
<hr class="line" />
<? include("include_region_list.php"); ?>
<h2><? echo $statename ?> State</h2>
<hr />
<? if($none == TRUE) {
echo "<p>No running stores have been entered yet for ".$statename. ".</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>

65
site/runshops/top.php Normal file
View File

@ -0,0 +1,65 @@
<?PHP
include("config.php");
require_once("rating/classes/include.all.php");
include("rating/int.to.words.php");
$results = mysql_query("SELECT COUNT(DISTINCT(grr.rating_ip)) AS respondents, ROUND(AVG(grr.rating_vote), 2) AS score, COUNT(grr.rating_vote) AS votes, gr.runshop_id, gr.runshop_name, gr.runshop_address, gr.runshop_address_two, gr.runshop_city, gr.runshop_state, gr.runshop_zip, gr.runshop_phone, gr.runshop_fax, gr.runshop_email, gr.runshop_website, gr.runshop_cart FROM ".$prefix."RunshopsRating AS grr RIGHT JOIN ".$prefix."Runshops AS gr ON gr.runshop_id = grr.runshop_id_fk GROUP BY grr.runshop_id_fk HAVING COUNT(grr.rating_vote) > 10 ORDER BY score DESC, votes DESC LIMIT 10");
// set the page title
$pagetitle = "Top Running Stores";
// set meta tags
$meta_keywords = "top ranked running stores";
$meta_description = "Top ranked running stores 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 Running Stores</h1>
<hr class="line" />
<? include("include_region_list.php"); ?>
<?
if($none == TRUE){
echo "<p>No running stores have been entered yet for $regionname.</p>";
}
?>
<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>

View File

@ -0,0 +1,98 @@
<?PHP
include("config.php");
if(!is_admin()){
header('Location: '.$site_url);
exit();
}
// Query to fetch non-validated races:
$results = mysql_query("SELECT runshop_id, runshop_name, runshop_address, runshop_address_two, runshop_city, runshop_state, runshop_zip, runshop_phone, runshop_fax, runshop_email, runshop_website, runshop_cart FROM ".$prefix."Runshops WHERE runshop_valid=0 ORDER BY runshop_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: Running Store 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>Unvalidated Running Stores</h1>
<hr />
<form method="post" action="validate_X.php" enctype="multipart/form-data">
<p>
<?
if($none == TRUE){
echo "There are no running stores waiting to be validated.";
}
?>
</p>
<div class="dtable">
<? while($row = mysql_fetch_array($results)) { ?>
<div class="drow"><div class="dcell"><a ref="<? echo "individual.php?runshop_id=$row[runshop_id]"; ?>"><? echo $row[runshop_name]; ?></a></div></div>
<div class="drow"><div class="dcell">Address: <? echo ("$row[runshop_address]"); if($row[runshop_address_two]) { echo ("<br /><span class='indent'>$row[runshop_address_two]</span>"); } echo("<br /><span class='indent'>$row[runshop_city], $row[runshop_state] $row[runshop_zip]</span>"); ?></div></div>
<div class="drow">
<div class="dcell">
<?
echo "Phone: </strong>$row[runshop_phone]<br /><strong class='indent'>Fax: </strong> $row[runshop_fax]";
?>
</div>
</div>
<div class="drow">
<div class="dcell">
<strong>Email:</strong> <? echo "<a href='mailto:$row[runshop_email]'>$row[runshop_email]</a>"; ?><br />
<strong>Website:</strong> <? echo "<a href='$row[runshop_website]' target='_blank'>$row[runshop_website]</a>"; ?> <? if ($row[runshop_cart] == 1) { echo ("**eCommerce Shopping Cart**"); } ?><br />
<a class="nav" href="<? echo "individual.php?runshop_id=$row[runshop_id]"; ?>">More information</a><br />
<input type="checkbox" value="<? echo($row[runshop_id]); ?>" name="validate[]"> Validate this running store.
<input type="checkbox" value="<? echo($row[runshop_id]); ?>" name="delete[]"> Delete this running store.
</div>
</div>
<? } ?>
</div>
<br />
<input type="submit" value="Validate Selected Running Stores" 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,39 @@
<?PHP
include("config.php");
if ((!isset($_POST['delete']) && !isset($_POST['validate'])) || !is_admin()) {
header('Location: '.$site_url);
die("validation_error");
}
if (isset($_POST['delete'])) {
// convert the array to a SQL friendly format
$deleteList = "(".implode(',', $_POST['delete']).")";
$deleteList = mysql_real_escape_string($deleteList);
// build the SQL query to delete the edits that are bad
$sql = "DELETE FROM ".$prefix."Runshops WHERE runshop_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']).")";
$idList = mysql_real_escape_string($idlist);
// build the SQL query
$sql = "UPDATE ".$prefix."Runshops
SET runshop_valid = 1
WHERE runshop_id IN $idlist;";
//echo $sql; exit;
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: ".$site_url."/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 running store?');" />
</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 running store?');" />
</form>
</div>

428
site/runshops/wiki_edit.php Normal file
View File

@ -0,0 +1,428 @@
<?PHP
include("config.php");
if(!isset($_GET[runshop_id]) AND !$_POST AND !is_numeric($_GET[runshop_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_shop])) {
$row = $_POST;
} else {
$runshop_idhere = mysql_real_escape_string($_GET[runshop_id]);
$results = mysql_query("SELECT * FROM ".$prefix."Runshops WHERE runshop_id=".$runshop_idhere);
$row = mysql_fetch_array($results);
}
//Get user's session data information
$username = base64_decode($_SESSION['user']);
$useruid = base64_decode($_SESSION['user_id']);
if (!is_admin()) {
if ( $row[runshop_valid] != 1 ) {
header('Location: '.$site_url.'/?error=shop_not_valid');
exit();
}
}
// set the page title
$pagetitle = "Edit A Running Store";
// set meta tags
$meta_keywords = "edit running store";
$meta_description = "edit screen for running store information";
?>
<? include("include_common_head.php"); ?>
<?
if($_POST[edit_shop] == 1){
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( $_GET[confirmed] == "yes" ) { ?>
<h1>Thank you</h1>
<p class=\"cont\">Thank you. Your shop should be added within 24 hours. You will now be redirected back to the home page.</p>
<META HTTP-EQUIV=Refresh CONTENT=\"4; URL=index.php\">
<? } else if($confirm == 1) { ?>
<h1>Edit a Shop: Step 2 of 2</h1>
<? } else if( ($confirm !=1) && ($_POST[confirm_entry] != 1)){ ?>
<h1>Edit a Shop: Step 1 of 2</h1>
<? } else if( ($_POST[edit_shop] == 1) && (!$errmsg) && ($_POST[confirm_entry] == 1)) { ?>
<h1>Thank you</h1>
<? } ?>
<hr class="line" />
<? include("include_region_list.php"); ?>
<? if(($confirm != 1) && ($_POST[confirm_entry] != 1) && $_GET[confirmed] != "yes") { ?>
<p class="cont">To edit a running store, simply change the data you wish. If you make a mistake, just hit the reset button. <font color="red">To save the changes as a NEW running store (for instance, if you have multiple locations), hit the "SAVE AS A NEW RUNNING STORE" button. To save changes to the existing running store entry, hit the "SAVE CHANGES TO YOUR RUNNING STORE" button. You will have a chance to review the data before confirming.</font></p>
<? } ?>
<? if( $_GET[confirmed] != "yes" && (($_POST[edit_shop] != 1) || ($errmsg) || (($confirm != 1) && ($_POST[confirm_entry] != 1))) ){ ?>
<form enctype="multipart/form-data" action="wiki_edit.php" method="post">
<p class="cont"><font color="red"><? echo $errmsg; ?></font></p>
<div class="dtable form">
<div class="drow">
<div class="dcell name">Store Name</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input type="text" name="runshop_name" value="<? echo stripslashes($row[runshop_name]); ?>" class="txt lngtext" />
</div>
</div>
<div class="drow">
<div class="dcell name">Address</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input type="text" name="runshop_address" value="<? echo stripslashes(htmlspecialchars($row[runshop_address])); ?>" class="txt lngtext" />
</div>
</div>
<div class="drow">
<div class="dcell name">Address 2</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input type="text" name="runshop_address_two" value="<? echo stripslashes(htmlspecialchars($row[runshop_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 type="text" name="runshop_city" value="<? echo stripslashes(htmlspecialchars($row[runshop_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="runshop_state">
<option value="0">Choose a State/Province</option>
<?
foreach($state_list as $key=>$value) {
if(strcmp($row[runshop_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 type="text" name="runshop_zip" value="<? echo stripslashes(htmlspecialchars($row[runshop_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 type="text" name="runshop_phone" value="<? echo stripslashes(htmlspecialchars($row[runshop_phone])); ?>" class="txt shotext" />
</div>
</div>
<div class="drow">
<div class="dcell name">Fax</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input type="text" name="runshop_fax" value="<? echo stripslashes(htmlspecialchars($row[runshop_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 type="text" name="runshop_email" value="<? echo stripslashes(htmlspecialchars($row[runshop_email])); ?>" class="txt lngtext" />
</div>
</div>
<div class="drow">
<div class="dcell name">Website</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input type="text" name="runshop_website" value="<? echo stripslashes(htmlspecialchars($row[runshop_website])); ?>" class="txt lngtext" placeholder="http://" />
</div>
</div>
<div class="drow">
<div class="dcell name">Online Shopping Cart: <br/> (Must be a fully functional ecommerce system)</div>
<div class="dcell divider"></div>
<div class="dcell value">
<select name="runshop_cart">
<option value="0" <? if ($row[runshop_cart] == 0) { echo "selected='selected'"; } ?>>No</option>
<option value="1" <? if ($row[runshop_cart] == 1) { echo "selected='selected'"; } ?>>Yes</option>
</select>
</div>
</div>
<div class="drow">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
for ($i = 0; $i < 10; $i++) echo("*");
echo (" TECHNOLOGY, COMMUNITY &amp; EDUCATION ");
for ($i = 0; $i < 10; $i++) echo("*");
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Key Tri-Specific Contact(s)</div>
<div class="dcell divider"></div>
<div class="dcell value">
<select name="runshop_contact">
<option value="0" <? if ($row[runshop_contact] == 0) { echo "selected='selected'"; } ?>>None</option>
<option value="1" <? if ($row[runshop_contact] == 1) { echo "selected='selected'"; } ?>>Yes, Their Names</option>
</select>
<input type="text" name="runshop_contact_names" value="<? echo stripslashes($row[runshop_contact_names]); ?>" class="txt shotext" />
</div>
</div>
<div class="drow">
<div class="dcell name">Diagnostic Equipment</div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
$explosion = array("");
if (!is_array($row[runshop_diagnostics])){ $explosion = explode(",", $row[runshop_diagnostics]); } else { $explosion = $row[runshop_diagnostics]; }
$list = mysql_query("SELECT * FROM ".$prefix."RunshopsDiagnostics ORDER BY diagnostic_name ASC");
echo("<input type=\"hidden\" name=\"runshop_diagnostics[]\" value=\"0\" >");
while ($fetch = mysql_fetch_array($list)) {
echo("<input type=\"checkbox\" name=\"runshop_diagnostics[]\" value=\"$fetch[diagnostic_id]\" ");
if (in_array($fetch[diagnostic_id], $explosion)){ echo "checked "; }
echo(">$fetch[diagnostic_name]");
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<?
for ($i = 0; $i < 25; $i++) echo("*");
echo (" BRANDS ");
for ($i = 0; $i < 25; $i++) echo("*");
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Running Shoes</div>
<div class="dcell divider"></div>
<div class="dcell value">
<p class="note">IMPORTANT: Running shoe brands of which you'll have almost
full size runs in stock of most of the important run models at almost all
times.</p>
<?
$explosion = array("");
if (!is_array($row[runshop_shoes])){ $explosion = explode(",", $row[runshop_shoes]); } else { $explosion = $row[runshop_shoes]; }
$list = mysql_query("SELECT * FROM ".$prefix."RunshopsShoes ORDER BY shoe_name ASC");
echo("<input type=\"hidden\" name=\"runshop_shoes[]\" value=\"0\" >");
while ($fetch = mysql_fetch_array($list)) {
echo("<span class=\"col\"><input type=\"checkbox\" name=\"runshop_shoes[]\" value=\"$fetch[shoe_id]\" ");
if (in_array($fetch[shoe_id], $explosion)){ echo "checked "; }
echo(" />$fetch[shoe_name]</span>");
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Socks</div>
<div class="dcell divider"></div>
<div class="dcell value">
<p class="note">IMPORTANT: Sock brands you'll keep in stock almost all the time.</p>
<?
$explosion = array("");
if (!is_array($row[runshop_socks])){ $explosion = explode(",", $row[runshop_socks]); } else { $explosion = $row[runshop_socks]; }
$list = mysql_query("SELECT * FROM ".$prefix."RunshopsSocks ORDER BY sock_name ASC");
echo("<input type=\"hidden\" name=\"runshop_socks[]\" value=\"0\" >");
while ($fetch = mysql_fetch_array($list)) {
echo("<span class=\"col\"><input type=\"checkbox\" name=\"runshop_socks[]\" value=\"$fetch[sock_id]\" ");
if (in_array($fetch[sock_id], $explosion)){ echo "checked "; }
echo(">$fetch[sock_name]</span>\n");
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Run Focused Apparel</div>
<div class="dcell divider"></div>
<div class="dcell value">
<p class="note">IMPORTANT: Run focus apparel brands you'll keep in stock, full size runs, almost all the time, season-appropriate.</p>
<?
$explosion = array("");
if (!is_array($row[runshop_apparel_run])){ $explosion = explode(",", $row[runshop_apparel_run]); } else { $explosion = $row[runshop_apparel_run]; }
$list = mysql_query("SELECT * FROM ".$prefix."RunshopsApparelRun ORDER BY apparel_run_name ASC");
echo("<input type=\"hidden\" name=\"runshop_apparel_run[]\" value=\"0\" >");
while ($fetch = mysql_fetch_array($list)) {
echo("<span class=\"col\"><input type=\"checkbox\" name=\"runshop_apparel_run[]\" value=\"$fetch[apparel_run_id]\" ");
if (in_array($fetch[apparel_run_id], $explosion)){ echo "checked "; }
echo(">$fetch[apparel_run_name]</span>\n");
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Tri Focused Apparel</div>
<div class="dcell divider"></div>
<div class="dcell value">
<p class="note">IMPORTANT: Run/tri apparel brands you'll keep in stock, full size runs, almost
all the time, season-appropriate.</p>
<?
$explosion = array("");
if (!is_array($row[runshop_apparel_tri])){ $explosion = explode(",", $row[runshop_apparel_tri]); } else { $explosion = $row[runshop_apparel_tri]; }
$list = mysql_query("SELECT * FROM ".$prefix."RunshopsApparelTri ORDER BY apparel_tri_name ASC");
echo("<input type=\"hidden\" name=\"runshop_apparel_tri[]\" value=\"0\" >");
while ($fetch = mysql_fetch_array($list)) {
echo("<span class=\"col\"><input type=\"checkbox\" name=\"runshop_apparel_tri[]\" value=\"$fetch[apparel_tri_id]\" ");
if (in_array($fetch[apparel_tri_id], $explosion)){ echo "checked "; }
echo(">$fetch[apparel_tri_name]</span>\n");
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Swim Gear</div>
<div class="dcell divider"></div>
<div class="dcell value">
<p class="note">IMPORTANT: Swimwear/Goggles: Brands you carry wide and deep, with models that are
swim-specific.</p>
<?
$explosion = array("");
if (!is_array($row[runshop_swimgear])){ $explosion = explode(",", $row[runshop_swimgear]); } else { $explosion = $row[runshop_swimgear]; }
$list = mysql_query("SELECT * FROM ".$prefix."ResourceSwimgear ORDER BY swimgear_name ASC");
echo("<input type=\"hidden\" name=\"runshop_swimgear[]\" value=\"0\" >");
while ($fetch = mysql_fetch_array($list)) {
echo("<span class=\"col\"><input type=\"checkbox\" name=\"runshop_swimgear[]\" value=\"$fetch[swimgear_id]\" ");
if (in_array($fetch[swimgear_id], $explosion)){ echo "checked "; }
echo(">$fetch[swimgear_name]</span>\n");
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name">Wetsuits</div>
<div class="dcell divider"></div>
<div class="dcell value">
<p class="note">IMPORTANT: Wetsuit brands of which you'll have 12 or more continually in stock during the season.</p>
<?
$explosion = array("");
if (!is_array($row[runshop_wetsuits])){ $explosion = explode(",", $row[runshop_wetsuits]); } else { $explosion = $row[runshop_wetsuits]; }
$list = mysql_query("SELECT * FROM ".$prefix."ResourceWetsuit ORDER BY wetsuit_name ASC");
echo("<input type=\"hidden\" name=\"runshop_wetsuits[]\" value=\"0\" >");
while ($fetch = mysql_fetch_array($list)) {
echo("<span class=\"col\"><input type=\"checkbox\" name=\"runshop_wetsuits[]\" value=\"$fetch[wetsuit_id]\" ");
if (in_array($fetch[wetsuit_id], $explosion)){ echo "checked "; }
echo(">$fetch[wetsuit_name]</span>\n");
}
?>
</div>
</div>
<div class="drow">
<div class="dcell name"></div>
<div class="dcell divider"></div>
<div class="dcell value">
<? for ($i = 0; $i < 60; $i++) echo("*"); ?>
</div>
</div>
<div class="drow">
<div class="dcell name">Store Hours</div>
<div class="dcell divider"></div>
<div class="dcell value">
<input type="text" name="runshop_hours" value="<? echo stripslashes(htmlspecialchars($row[runshop_hours])); ?>" class="txt lngtext" /></td>
</div>
</div>
<div class="drow">
<div class="dcell name">Runs &amp; Classes</div>
<div class="dcell divider"></div>
<div class="dcell value">
<textarea name="runshop_classes" class="txt lngtext" placeholder="Place here times and days of regular runs emanating from the shop, with distances and pace (easy-moderate-fast); also whether you host running classes, when, and any cost associated.">
<? if($row[runshop_classes]){ echo strip_tags(stripslashes($row[runshop_classes])); } ?>
</textarea>
</div>
</div>
<div class="drow">
<div class="dcell name">Shop Info</div>
<div class="dcell divider"></div>
<div class="dcell value">
<textarea name="runshop_info" class="txt lngtext" placeholder="Please write some information about your shop.">
<? if($row[runshop_info]){ echo strip_tags(stripslashes($row[runshop_info])); } ?>
</textarea>
</div>
</div>
<div class="drow">
<div class="dcell name">Directions</div>
<div class="dcell divider"></div>
<div class="dcell value">
<textarea name="runshop_directions" class="txt lngtext" placeholder="Please describe how to get to your shop from your surrounding area.">
<? if($row[runshop_directions]) { echo strip_tags(stripslashes($row[runshop_directions])); } ?>
</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_shop" value="Save As A New Store" class="btn" />
<input type="reset" value="Reset" class="btn">
<input type="hidden" name="edit_shop" value="1">
<input type="hidden" name="runshop_id" value="<? echo($row[runshop_id]); ?>">
<? // need to temporary set the field as being valid ?>
<input type="hidden" name="runshop_valid" value="1">
<input type="hidden" name="runshop_submitted_by" value="<? echo($row[runshop_submitted_by]); ?>">
<input type="hidden" name="edited_by" value="<? echo($useruid); ?>">
</div>
</div>
</div>
</form>
<?
} else {
if ($confirm == 1) {
$confirm = 0;
include("include_edit_confirm.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>

View File

@ -0,0 +1,142 @@
<?PHP
if (!$_POST){ header('Location: '.$site_url.'/?error=no_post'); }
/*
FIELD NAMES:
runshop_id
runshop_name
runshop_name_tag
runshop_address
runshop_address_two
runshop_city
runshop_state
runshop_state_tag
runshop_zip
runshop_phone
runshop_fax
runshop_email
runshop_website
runshop_cart
runshop_contact
runshop_contact_names
runshop_diagnostics
runshop_shoes
runshop_socks
runshop_apparel_run
runshop_apparel_tri
runshop_swimgear
runshop_wetsuits
runshop_hours
runshop_classes
runshop_info
runshop_directions
runshop_submitted_by
runshop_valid
runshop_shopper_tags
*/
/* Need to ltrim and rtrim commas before insertion */
//Insert into database
$pass = 'abc123';
$errmsg = NULL;
//Check for blank fields
if ((!$_POST[runshop_name])) $errmsg = $errmsg.'Shop name, ';
if (!$_POST[runshop_city]) $errmsg = $errmsg.'City, ';
if (!$_POST[runshop_state]) $errmsg = $errmsg.'State, ';
if (!$_POST[runshop_address]) $errmsg = $errmsg.'Address, ';
if (!$_POST[runshop_phone]) $errmsg = $errmsg.'Phone, ';
if (!$_POST[runshop_email]) $errmsg = $errmsg.'Email, ';
if (!$_POST[runshop_hours]) $errmsg = $errmsg.'Shop hours, ';
if ($_POST[runshop_contact] == 1 && !$_POST[runshop_contact_names]) $errmsg = $errmsg.'Contact names, ';
if (strlen($_POST[runshop_classes]) < 4) $errmsg = $errmsg.'Runs &amp; classes, ';
if (strlen($_POST[runshop_info]) < 4) $errmsg = $errmsg.'Shop info, ';
if (strlen($_POST[runshop_directions]) < 4) $errmsg = $errmsg.'Directions, ';
if (isset($errmsg)) {
$errmsg = 'The following fields cannot be left blank: '.$errmsg;
$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[runshop_website]) && $_POST[runshop_website] != "") {
// Contains invalid characters.
$errmsg = $errmsg."Invalid Web Address<br />";
}*/
if( preg_match('/[^a-zA-Z0-9\. ]/', $_POST[runshop_name]) ) {
// Contains invalid characters.
$errmsg = "Please use only letters and numbers in the name";
}
// BEGIN ERROR MESSAGE CHECK
if(!$errmsg){
$name = mysql_real_escape_string(trim($_POST[runshop_name]));
$name_tag = mysql_real_escape_string(strtolower(str_replace(" ","", $name)));
if(strlen($nametag) > 12){ //Shorten it
$name_tag = substr($nametag, 0, 12);
}
$address = mysql_real_escape_string(trim($_POST[runshop_address]));
$address_two = mysql_real_escape_string(trim($_POST[runshop_address_two]));
$city = mysql_real_escape_string(trim($_POST[runshop_city]));
$state = mysql_real_escape_string($_POST[runshop_state]);
$state_tag = mysql_real_escape_string(strtolower(str_replace(" ","", $state)));
$zip = mysql_real_escape_string(trim($_POST[runshop_zip]));
$phone = mysql_real_escape_string(trim($_POST[runshop_phone]));
$fax = mysql_real_escape_string(trim($_POST[runshop_fax]));
$email = mysql_real_escape_string(trim($_POST[runshop_email]));
$website = mysql_real_escape_string(trim($_POST[runshop_website]));
$cart = mysql_real_escape_string(trim($_POST[runshop_cart]));
$contact = mysql_real_escape_string($_POST[runshop_contact]);
if ( $contact == 0 ){ $contact_names = NULL; }else{ $contact_names = mysql_real_escape_string(trim($_POST[runshop_contact_names])); }
/* Need to ltrim and rtrim commas before insertion --> or ltrim/rtrim before implosion*/
$diagnostics = mysql_real_escape_string($_POST[runshop_diagnostics]);
$shoes = mysql_real_escape_string($_POST[runshop_shoes]);
$swimgear = mysql_real_escape_string($_POST[runshop_swimgear]);
$wetsuits = mysql_real_escape_string($_POST[runshop_wetsuits]);
$socks = mysql_real_escape_string($_POST[runshop_socks]);
$apparel_run = mysql_real_escape_string($_POST[runshop_apparel_run]);
$apparel_tri = mysql_real_escape_string($_POST[runshop_apparel_tri]);
$hours = mysql_real_escape_string(trim($_POST[runshop_hours]));
$classes = mysql_real_escape_string(substr(trim($_POST[runshop_classes]), 0, 4096));
$info = mysql_real_escape_string(substr(trim($_POST[runshop_info]), 0, 4096));
$directions = mysql_real_escape_string(substr(trim($_POST[runshop_directions]), 0, 4096));
$submitted_by = mysql_real_escape_string($_POST[runshop_submitted_by]);
$id = mysql_real_escape_string($_POST[runshop_id]);
$edited_by = mysql_real_escape_string($_POST[edited_by]);
$edit_timestamp = mysql_real_escape_string(time());
// BEGIN CONFIRM ENTRY CHECK
if($_POST[confirm_entry] == 1){
if(isset($_POST[new_shop])){
$sql = "INSERT INTO ".$prefix."Runshops (runshop_name, runshop_name_tag, runshop_address, runshop_address_two, runshop_city, runshop_state, runshop_state_tag, runshop_zip, runshop_phone, runshop_fax, runshop_email, runshop_website, runshop_cart, runshop_contact, runshop_contact_names, runshop_diagnostics, runshop_shoes, runshop_socks, runshop_apparel_run, runshop_apparel_tri, runshop_swimgear, runshop_wetsuits, runshop_hours, runshop_classes, runshop_info, runshop_directions, runshop_submitted_by, runshop_valid) VALUES ('$name', '$name_tag', '$address', '$address_two', '$city', '$state', '$state_tag', '$zip', '$phone', '$fax', '$email', '$website', '$cart', $contact, '$contact_names', ',$diagnostics,', ',$shoes,', ',$socks,', ',$apparel_run,', ',$apparel_tri,', ',$swimgear,', ',$wetsuits,', '$hours', '$classes', '$info', '$directions', $submitted_by, 0)";
//echo("shop 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."RunshopsEdits (runshop_id_fk, editor_user_id_fk, edit_timestamp, runshop_name, runshop_name_tag, runshop_address, runshop_address_two, runshop_city, runshop_state, runshop_state_tag, runshop_zip, runshop_phone, runshop_fax, runshop_email, runshop_website, runshop_cart, runshop_contact, runshop_contact_names, runshop_diagnostics, runshop_shoes, runshop_socks, runshop_apparel_run, runshop_apparel_tri, runshop_swimgear, runshop_wetsuits, runshop_hours, runshop_classes, runshop_info, runshop_directions, runshop_submitted_by, runshop_valid) VALUES ('$id', '$edited_by', '$edit_timestamp', '$name', '$name_tag', '$address', '$address_two', '$city', '$state', '$state_tag', '$zip', '$phone', '$fax', '$email', '$website', '$cart', $contact, '$contact_names', ',$diagnostics,', ',$shoes,', ',$socks,', ',$apparel_run,', ',$apparel_tri,', ',$swimgear,', ',$wetsuits,', '$hours', '$classes', '$info', '$directions', $submitted_by, 0)";
mysql_query($sql) OR die(mysql_error());
header('Location: '.$site_url.'/individual.php?runshop_id='.$id.'&wiki_change=success');
} else {
header('Location: '.$site_url.'/individual.php?runshop_id='.$id.'&changes=failure');
}
} else {
//echo("shop NOT entered.");
$confirm = 1;
}
// END CONFIRM ENTRY CHECK
}
// END ERROR MESSAGE CHECK
?>

View File

@ -0,0 +1,105 @@
<?PHP include("config.php");
if(!is_admin()){
header('Location:'.$site_url.'/');
exit();
}
// Query to fetch non-validated running stores:
$results = mysql_query("SELECT edit_id, runshop_name, runshop_city, runshop_state, runshop_info, edit_timestamp, runshop_submitted_by, editor_user_id_fk FROM ".$prefix."RunshopsEdits 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: Running Store 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>Unvalidated Public Edits</h1>
<hr class="line" />
<form method="post" action="wiki_validate_X.php" enctype="multipart/form-data">
<p>
<?
if($none == TRUE){
echo "There are no edits waiting to be validated.";
}
?>
</p>
<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[runshop_submitted_by]) { $boolEditorIsOwner = true; }
?>
<div class="drow"><div class="dcell"><a href="<? echo "wiki_view.php?edit_id=$row[edit_id]"; ?>"><? echo $row[runshop_name]; ?></a></div></div>
<div class="drow"><div class="dcell">Edited on: <? 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 submitter)"; } else { echo ""; } ?></div></div>
<div class="drow">
<div class="dcell">Info:
<?
if(strlen($row[runshop_info]) > 400){
$phrase = "&hellip;"; }else{
$phrase = ""; }
echo substr(htmlspecialchars(stripslashes($row[runshop_info])), 0, 160);
echo $phrase;
?>
</div>
</div>
<div class="drow">
<div class="dcell">
<strong>Location:</strong> <? echo "$row[runshop_city], $row[runshop_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.
</div>
</div>
<? } ?>
</div>
<input type="submit" value="Process Selected Running Stores" 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,75 @@
<?PHP
include("config.php");
if (!$_POST || !is_admin()){ header('Location: '.$site_url.'/'); }
// error checking
if(!isset($_POST['delete']) && !isset($_POST['validate'])) 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."RunshopsEdits 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."RunshopsEdits WHERE edit_id IN $validateList";
$results = mysql_query($sql) OR die(mysql_error());
// Loop through running store edits shifting edits over
while($row = mysql_fetch_array($results)) {
$sql = "UPDATE ".$prefix."Runshops
SET runshop_name = '".mysql_escape_string($row[runshop_name])."',
runshop_name_tag = '".mysql_escape_string($row[runshop_name_tag])."',
runshop_address = '".mysql_escape_string($row[runshop_address])."',
runshop_address_two = '".mysql_escape_string($row[runshop_address_two])."',
runshop_city = '".mysql_escape_string($row[runshop_city])."',
runshop_state = '".mysql_escape_string($row[runshop_state])."',
runshop_state_tag = '".mysql_escape_string($row[runshop_state_tag])."',
runshop_zip = '".mysql_escape_string($row[runshop_zip])."',
runshop_phone = '".mysql_escape_string($row[runshop_phone])."',
runshop_fax = '".mysql_escape_string($row[runshop_fax])."',
runshop_email = '".mysql_escape_string($row[runshop_email])."',
runshop_website = '".mysql_escape_string($row[runshop_website])."',
runshop_cart = '".mysql_escape_string($row[runshop_cart])."',
runshop_contact = '".mysql_escape_string($row[runshop_contact])."',
runshop_contact_names = '".mysql_escape_string($row[runshop_contact_names])."',
runshop_diagnostics = ',".mysql_escape_string($row[runshop_diagnostics])."',
runshop_shoes = ',".mysql_escape_string($row[runshop_shoes])."',
runshop_swimgear = ',".mysql_escape_string($row[runshop_swimgear])."',
runshop_wetsuits = ',".mysql_escape_string($row[runshop_wetsuits])."',
runshop_socks = ',".mysql_escape_string($row[runshop_socks])."',
runshop_apparel_run = ',".mysql_escape_string($row[runshop_apparel_run])."',
runshop_apparel_tri = ',".mysql_escape_string($row[runshop_apparel_tri])."',
runshop_hours = '".mysql_escape_string($row[runshop_hours])."',
runshop_classes = '".mysql_escape_string($row[runshop_classes])."',
runshop_info = '".mysql_escape_string($row[runshop_info])."',
runshop_directions = '".mysql_escape_string($row[runshop_directions])."'
WHERE runshop_id = '$row[runshop_id_fk]'";
//echo $sql;
//exit();
mysql_query($sql) OR die(mysql_error());
$sql = "INSERT INTO ".$prefix."RunshopsEditors (runshop_id_fk, user_id_fk, edit_timestamp) VALUES ('$row[runshop_id_fk]', '$row[editor_user_id_fk]', '$row[edit_timestamp]')";
mysql_query($sql) OR die(mysql_error());
$sql = "DELETE FROM ".$prefix."RunshopsEdits WHERE edit_id = $row[edit_id]";
mysql_query($sql) OR die(mysql_error());
}
}
header('Location: '.$site_url.'/wiki_validate.php');
?>

304
site/runshops/wiki_view.php Normal file
View File

@ -0,0 +1,304 @@
<?PHP
if (!is_numeric($_GET[edit_id])) {
header('Location:'.$site_url.'/?error=invalid_id');
}
include("config.php");
// only admins can validate
if(!is_admin()){
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."RunshopsEdits WHERE edit_id = '".$edit_id_here."' LIMIT 1") OR die(mysql_error());
$row = mysql_fetch_array($results);
if (!$row) { header('Location:'.$site_url.'/?error=no_entry'); }
// set the page title
$pagetitle = $row[runshop_name];
// set meta tags
$meta_keywords = "triathlon, ".$row[runshop_name].", ".$row[runshop_state]." triathlon running store";
$meta_description = "Considering shopping at ".$row[runshop_name]."? Here is all of the information about this running store.";
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 style="display: inline; height: 16px; margin-bottom: 20px;"><!-- class="content-title"--><? echo stripslashes($row[runshop_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[runshop_address])); ?>
<br />
<strong>Street Address Two: </strong><? echo stripslashes(htmlspecialchars($row[runshop_address_two])); ?>
<br />
<strong>City: </strong><? echo stripslashes(htmlspecialchars($row[runshop_city])); ?>
<br />
<strong>State: </strong><? echo stripslashes(htmlspecialchars($row[runshop_state])); ?>
<br />
<strong>Zip/Postal Code: </strong><? echo stripslashes(htmlspecialchars($row[runshop_zip])); ?>
<br />
<strong>Phone: </strong><? echo stripslashes(htmlspecialchars($row[runshop_phone])); ?>
<br />
<strong>Fax / Alternate Phone: </strong><? echo stripslashes(htmlspecialchars($row[runshop_fax])); ?>
<br />
<strong>E-mail: </strong><a href="mailto:<? echo $row[runshop_email]; ?>"><? echo stripslashes(htmlspecialchars($row[runshop_email])); ?></a>
<br />
<strong>Website: </strong><a href="<? echo $row[runshop_website]; ?>" target="_blank"><? echo $row[runshop_website]; ?></a><? if ($row[runshop_cart] == 1) { echo (" **eCommerce Shopping Cart**"); } ?>
<br />
<br />
<div class="indentlarge">
<?
for ($i = 0; $i < 15; $i++) echo("*");
echo (" TECHNOLOGY, COMMUNITY &amp; EDUCATION ");
for ($i = 0; $i < 15; $i++) echo("*");
?>
</div>
<br />
<strong>Key Tri-Specific Contact(s): </strong><? if ($row[runshop_contact] == 0) { echo "None"; } else { echo "Yes, Their Names - "; echo stripslashes($row[runshop_contact_names]); } ?>
<br />
<strong>Diagnostic Equipment: </strong><?
$row[runshop_diagnostics] = ltrim(rtrim($row[runshop_diagnostics], ", "), ", ");
if ($row[runshop_diagnostics]) {
$sql = ("SELECT * FROM ".$prefix."RunshopsDiagnostics WHERE diagnostic_id IN ($row[runshop_diagnostics]) ORDER BY diagnostic_name ASC");
//echo $sql;
$fetch = mysql_query($sql) or die(mysql_error());
$diagnostic_list = "";
while ($list = mysql_fetch_array($fetch)) {
$diagnostic_list = $diagnostic_list."$list[diagnostic_name], ";
}
$diagnostic_list = rtrim($diagnostic_list, ', ');
}
if ($diagnostic_list) {echo $diagnostic_list;} else {echo "None";}
?>
<br /><br />
<div class="indentlarge">
<?
for ($i = 0; $i < 36; $i++) echo("*");
echo (" BRANDS ");
for ($i = 0; $i < 36; $i++) echo("*");
?>
</div>
<br />
<strong>Shoes: </strong><?
$row[runshop_shoes] = ltrim(rtrim($row[runshop_shoes], ", "), ", ");
$sql = ("SELECT * FROM ".$prefix."RunshopsShoes WHERE shoe_id IN ($row[runshop_shoes]) ORDER BY shoe_name ASC");
//echo $sql;
$fetch = mysql_query($sql) or die(mysql_error());
$shoe_list = "";
while ($list = mysql_fetch_array($fetch)) {
$shoe_list = $shoe_list."$list[shoe_name], ";
}
$shoe_list = rtrim($shoe_list, ', ');
if ($shoe_list) {echo $shoe_list;} else {echo "None";}
?>
<br />
<strong>Socks: </strong><?
$row[runshop_socks] = ltrim(rtrim($row[runshop_socks], ", "), ", ");
$sql = ("SELECT * FROM ".$prefix."RunshopsSocks WHERE sock_id IN ($row[runshop_socks]) ORDER BY sock_name ASC");
//echo $sql;
$fetch = mysql_query($sql) or die(mysql_error());
$sock_list = "";
while ($list = mysql_fetch_array($fetch)) {
$sock_list = $sock_list."$list[sock_name], ";
}
$sock_list = rtrim($sock_list, ', ');
if ($sock_list) {echo $sock_list;} else {echo "None";}
?>
<br />
<strong>Run-Focused Apparel: </strong><?
$row[runshop_apparel_run] = ltrim(rtrim($row[runshop_apparel_run], ", "), ", ");
$sql = ("SELECT * FROM ".$prefix."RunshopsApparelRun WHERE apparel_run_id IN ($row[runshop_apparel_run]) ORDER BY apparel_run_name ASC");
//echo $sql;
$fetch = mysql_query($sql) or die(mysql_error());
$apparel_run_list = "";
while ($list = mysql_fetch_array($fetch)) {
$apparel_run_list = $apparel_run_list."$list[apparel_run_name], ";
}
$apparel_run_list = rtrim($apparel_run_list, ', ');
if ($apparel_run_list) {echo $apparel_run_list;} else {echo "None";}
?>
<br />
<strong>Tri-Focused Apparel: </strong><?
$row[runshop_apparel_tri] = ltrim(rtrim($row[runshop_apparel_tri], ", "), ", ");
if ($row[runshop_apparel_tri]) {
$sql = ("SELECT * FROM ".$prefix."RunshopsApparelTri WHERE apparel_tri_id IN ($row[runshop_apparel_tri]) ORDER BY apparel_tri_name ASC");
//echo $sql;
$fetch = mysql_query($sql) or die(mysql_error());
$apparel_tri_list = "";
while ($list = mysql_fetch_array($fetch)) {
$apparel_tri_list = $apparel_tri_list."$list[apparel_tri_name], ";
}
$apparel_tri_list = rtrim($apparel_tri_list, ', ');
}
if ($apparel_tri_list) {echo $apparel_tri_list;} else {echo "None";}
?>
<br />
<strong>Swim Gear: </strong><?
$row[runshop_swimgear] = ltrim(rtrim($row[runshop_swimgear], ", "), ", ");
$sql = ("SELECT * FROM ".$prefix."ResourceSwimgear WHERE swimgear_id IN ($row[runshop_swimgear]) ORDER BY swimgear_name ASC");
//echo $sql;
$fetch = mysql_query($sql) or die(mysql_error());
$swimgear_list = "";
while ($list = mysql_fetch_array($fetch)) {
$swimgear_list = $swimgear_list."$list[swimgear_name], ";
}
$swimgear_list = rtrim($swimgear_list, ', ');
if ($swimgear_list) {echo $swimgear_list;} else {echo "None";}
?>
<br />
<strong>Wetsuits: </strong><?
$row[runshop_wetsuits] = ltrim(rtrim($row[runshop_wetsuits], ", "), ", ");
if ($row[runshop_wetsuits]) {
$sql = ("SELECT * FROM ".$prefix."ResourceWetsuit WHERE wetsuit_id IN ($row[runshop_wetsuits]) ORDER BY wetsuit_name ASC");
//echo $sql;
$fetch = mysql_query($sql) or die(mysql_error());
$wetsuit_list = "";
while ($list = mysql_fetch_array($fetch)) {
$wetsuit_list = $wetsuit_list."$list[wetsuit_name], ";
}
$wetsuit_list = rtrim($wetsuit_list, ', ');
}
if ($wetsuit_list) {echo $wetsuit_list;} else {echo "None";}
?>
<br /><br />
<div class="indentlarge">
<?
for ($i = 0; $i < 80; $i++) echo("*");
?>
</div>
<br />
<strong>Shop Hours: </strong><? echo stripslashes(htmlspecialchars($row[runshop_hours])); ?>
<br /><br />
<strong>Runs &amp; Classes: </strong><? echo stripslashes(stripslashes($row[runshop_classes])) ?>
<br /><br />
<strong>Shop Info: </strong><? echo stripslashes(stripslashes($row[runshop_info])) ?>
<br /><br />
<strong>Directions: </strong><? echo stripslashes(stripslashes($row[runshop_directions])); ?>
<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>