[php]
// Get model number from query string.
$model = $_GET[‘mod’];
// Check that a model number was passed.
if(isset($model)) {
// Build unique value to validate.
$cond = substr($model, 1, 1);
$tank = substr(substr($model, -7),0, 2);
$coil = substr(substr($model, -4),0, 1);
$HP = substr($model, 3, 2);
$uniVal = $cond . $coil;
// Set include based off unique value.
switch ($uniVal) {
case ‘EA’:
// ==== If tank is 5 gal, then Chill&Flow. ====
if($tank == ’05’) {
$series = ‘CF’;
break;
// ==== If tank is 20 gal, then ChillStar. ====
} elseif ($tank == ’20’) {
$series = ‘ChilStar’;
break;
// ==== If tank ends in 00 gal, then MA. ====
} elseif ($tank == ’00’) {
$series = ‘MA’;
break;
}
// ==== MA series. ====
case ‘MA’:
// ==== If tank is 20 gal, then ChillStar. ====
if ($tank == ’20’) {
$series = ‘ChilStar’;
break;
// ==== If tank ends in 00 gal, then MA. ====
} elseif ($tank == ’00’) {
$series = ‘MA’;
break;
}
// ====V-Scroll. Any model that starts with ‘PS’ and has a ‘V’ condenser call out.====
case ‘SV’:
$series = ‘vScroll’;
break;
// =====V-Piston. Any model that starts with ‘PB’, has a ‘V’ condenser call out, and is under 80 HP.=====
case ‘BV’:
$series = ‘vPiston’;
break;
case ‘BA’:
// ====More than 80 HP.====
// ====V-Screw. Any model that starts with ‘PB’, has a ‘A’ condenser call out, and is over 80 HP.====
$HP2 = substr($model, 3, 3);
if($HP >= ’80’ || $HP2 >= ’80’) {
$series = ‘vScrew’;
break;
}
}
// Get HTML template.
$template = file_get_contents(“https://prochiller.com/phpTemplate1/”);
$result= include(‘/home/prorefadmin/public_html/wp-includes/db_conn.php’);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
// Keys from template and matching Values
$a = array(
‘{{MODEL}}’ => $row[‘model’],
‘{{MCA_120_1_60}}’ => $row[‘120_1_60_mca_amps’],
‘{{MCA_230_1_60}}’ => $row[‘230_1_60_mca_amps’],
‘{{MCA_230_3_60}}’ => $row[‘230_3_60_mca_amps’],
‘{{MCA_460_3_60}}’ => $row[‘460_3_60_mca_amps’],
‘{{MOP_120_1_60}}’ => $row[‘120_1_60_mop_amps’],
‘{{MOP_230_1_60}}’ => $row[‘230_1_60_mop_amps’],
‘{{MOP_230_3_60}}’ => $row[‘230_3_60_mop_amps’],
‘{{MOP_460_3_60}}’ => $row[‘460_3_60_mop_amps’],
‘{{DIMENSIONS}}’ => $row[‘dims’],
‘{{FRAME}}’ => $row[‘frame_material’],
‘{{HOUSING}}’ => $row[‘housing_material’],
‘{{TANK}}’ => $row[‘tank_gal’] . ‘ Gal’,
‘{{COMPRESSOR_HP}}’ => $row[‘compressor_hp’],
‘{{CONDENSER}}’ => $row[‘condenser_type’],
‘{{1_GLYCOL_PUMP_HP}}’ => $row[‘circ_pump_HP’],
‘{{2_GLYCOL_PUMP_HP}}’ => $row[‘proc_pump_hp’],
‘{{GLYCOL_CONN_SIZE}}’ => $row[‘field_connection_size’],
‘{{HX}}’ => $row[‘hx’],
‘{{CONTROLS}}’ => $row[‘control’],
‘{{ELECTRIC_ENCL}}’ => $row[‘electric_encl’],
‘{{SHIP_WT}}’ => $row[‘weight_shipping_lbs’],
‘{{DB_1M}}’ => $row[‘db’],
‘{{REFRIG}}’ => $row[‘refrigerant’],
‘{{BTUH_20_DEG}}’ => $row[‘cap_20f_leave_90f_amb_btu’],
‘{{BTUH_25_DEG}}’ => $row[‘cap_25f_leave_90f_amb_btu’],
‘{{BTUH_30_DEG}}’ => $row[‘cap_30f_leave_90f_amb_btu’],
‘{{BTUH_35_DEG}}’ => $row[‘cap_35f_leave_90f_amb_btu’],
‘{{EXP_FITTINGS}}’ => $row[‘exp_fittings’],
‘{{CHILLER_IMG}}’ => $row[‘chiller_img’],
‘{{DESC}}’ => $row[‘description’],
);
}
}
// Fill chiller includes blurb.
$inc_blurb = include(‘/home/prorefadmin/public_html/wp-includes/db_conn_inc_blurb.php’);
$include_Block_array = array();
if ($inc_blurb->num_rows > 0) {
while($row = $inc_blurb->fetch_assoc()) {
$include_Block_array[$row[‘field_template’]] = $row[‘field_text’];
$include_Block_array[$row[‘field_name_template’]] = $row[‘field_name’];
}
}
// Function to loop through keys on template and replace with values.
function fill_template($template, $a, $include_Block_array)
{
foreach($a as $key => $value) {
if(!isset($value) || is_null($value)) {
$template = str_replace($key, ‘N/A’, $template);
}
else
{
$template = str_replace($key, $value, $template);
}
}
foreach($include_Block_array as $key => $value) {
$template = str_replace($key, $value, $template);
}
return $template;
}
// Return populated page.-
echo fill_template($template, $a, $include_Block_array);
}
else {
// Don’t show anything.
}
[/php]