"New South Wales", "nt"=>"Northern Territory", "qld"=>"Queensland", "sa"=>"South Australia", "vic"=>"Victoria", "wa"=>"Western Australia", "tas"=>"Tasmania"); if (!isset($sORr)) { $sORr = 'sales';}// is it a sales or rental? if (!isset($cORg)) { $cORg = 'glom';} // for templates pourposes, client template or group template if (!isset($ag)) { $ag = 'glom';} // what agent? if (!isset($daily)) { $daily = 0;} if (!isset($all_properties)){ $all_properties = 0;} $and = ''; $isitclient = "&ag=$ag&sORr=$sORr&cORg=$cORg"; $type = 'search'; $title1 = ''; $title2 = 'Email Adviser Form'; $group = $cORg; # ----------------------------------------------------------------------------------------- # Got here so we open the database # ----------------------------------------------------------------------------------------- $link = connectToDatabase(); if (!$link) { errorPage("
  • DATABASE CONNECTION ERROR ****
    " . mysql_error()); exit(); } # ----------------------------------------------------------------------------------------- # if no action then we open the menu # ----------------------------------------------------------------------------------------- if (!isset($action)) { // Initialize template $tpl = new FastTemplate("../templates"); $start = $tpl->utime(); // Benchmarking $tpl->define(array( main => "glom-main-template.tpl", adviser => "email-adviser-template.tpl", )); $tpl->define_dynamic ( "region", "adviser"); $tpl->define_dynamic ( "suburb", "adviser"); $tpl->define_dynamic ( "bedroom", "adviser"); $tpl->define_dynamic ( "bathroom", "adviser"); $tpl->define_dynamic ( "pricemin", "adviser"); $tpl->define_dynamic ( "pricemax", "adviser"); $tpl->define_dynamic ( "rowphoto", "main"); $tpl->define_dynamic ( "rowtext", "main"); $tpl->define_dynamic ( "image", "main"); $tpl->define_dynamic ( "agents", "main"); $tpl->define_dynamic ( "saleslinks", "main"); $tpl->define_dynamic ( "rentallinks", "main"); $tpl->clear_dynamic(rowphoto); $tpl->clear_dynamic(rowtext); # ----------------------------------------------------------------------------------------- # # ----------------------------------------------------------------------------------------- // if ($sORr == 'sales') // { // $tpl->clear_dynamic(rentallinks); // $rORno = "RIGHT(Properties.Property,2) != '-r'"; // if it is sales we want only the for sales properties // } // else // { // $tpl->clear_dynamic(saleslinks); // $rORno = "RIGHT(Properties.Property,2) = '-r'"; // if it is sales we want only the for sales properties // } if ($cORg == $ag) { $tpl->parse(AGENTSIMAGE,".image"); $sql = "SELECT DISTINCT Properties.Agent, Agents.AgentName FROM Properties INNER JOIN Agents ON Properties.Agent = Agents.Agent WHERE Agents.AgentGroup = '$group' AND Agents.Agent NOT LIKE 'pr%' AND Agents.AgentName NOT LIKE 'Australian Private%' AND $rORno ORDER BY Agents.AgentName"; $res = mysql_unbuffered_query($sql); while ($data = mysql_fetch_assoc($res)) { $tpl->assign( array( AGENTCODE => $data['Agent'], AGENTNAME => $data['AgentName'], ) ); $tpl->parse(AGENTSBIT,".agents"); } $tpl->assign( array( AGENTSTATE => '', ) ); $state = ""; } else { // do the state $sql = "SELECT * from Agents Where Agent = '" . $ag . "'"; $res = mysql_unbuffered_query($sql); $data = mysql_fetch_assoc($res); $tpl->assign( array( AGENTSTATE => 'in ' . $states_name[$data['AgentState']], ) ); $state = $data['AgentState']; $and = " AND Properties.Agent = '".$ag."' "; $tpl->clear_dynamic(image); $tpl->clear_dynamic(agents); } // do the colours $sql = "SELECT * FROM AgentColours Where Agent = '" . $ag . "'"; $res = mysql_unbuffered_query($sql); $data = mysql_fetch_assoc($res); $tpl->assign( array( TITLEMAIN => "Real Estate", TITLE1 => $title1, TITLE2 => $title2, SORR => $sORr, AGENTCODE => $ag, COLOURBG => $data['colourBg'], COLOURTEXT => $data['colourText'], COLOURLINK => $data['colourLink'], COLOURVLINK => $data['colourvLink'], COLOURALINK => $data['colouraLink'], COLOUR1 => $data['colour1'], COLOUR2 => $data['colour2'], COLOR4 => substr($data['colour4'],1), COLOUR3 => $data['colour3'], COLOUR4 => $data['colour4'], FONT1 => $data['font1'], FONT2 => $data['font2'], FONT3 => $data['font3'], FONT4 => $data['font4'] ) ); $sql1 = "SELECT *,LEFT(Region, LOCATE('-',Region) -1) as State FROM Regions ORDER BY Region,RegionName"; $res1 = mysql_unbuffered_query($sql1); while ($dt = mysql_fetch_assoc($res1)) { $tpl->assign(array( REGIONSTATENAME => $dt['State'] .";". $dt['Region'].";". $dt['RegionName'], )); $tpl->parse(REGIONS,".region"); } // do the suburbs if (! get_cfg_var('safe_mode')) { set_time_limit(900); } $sql_sub = "SELECT Region,Suburb FROM Suburbs ORDER BY LEFT(Region, LOCATE('-',Region) -1), Suburb"; $res = mysql_unbuffered_query($sql_sub); while ($data = mysql_fetch_assoc($res)) { $tpl->assign(array( SUBURBSTATENAME => $data['Region'].';'.$data['Suburb'], )); $tpl->parse(SUBURBS,".suburb"); } $tpl->assign(array( ISITCLIENT => $isitclient, CLIENTITIS => "&sORr=$sORr&cORg=$cORg", )); $tpl->parse(SEARCHUSE,adviser); $tpl->assign(array( OTHERPAGES => '', OTHERLINKS => '', ORDERBY => '', CLICKON => '' )); $tpl->parse(MAIN, main); $tpl->FastPrint(MAIN); $end = $tpl->utime(); $runtime = round(($end - $start),2); echo "
    Processed in $runtime seconds
    \n"; $lk = mysql_query("DROP TABLE IF EXISTS Main_Temp_Table",$link); mysql_close($link); exit; } # ----------------------------------------------------------------------------------------- # if some action and the user have chosen to work with the Agents table # but have informed the agent code then we open a form with all the agent information # ----------------------------------------------------------------------------------------- elseif ($action == 'Create_Adviser') { if ($email_address == "") { errorPage("
  • The field e-mail address is compulsory
  • "); exit(); } if (!isValidEmail($email_address)) { errorPage("
  • Please enter a valid e-mail address
  • "); exit(); } $sub = urlencode($suburb); $reg = urlencode($search_region); $p_type = urlencode($prop_type); $search_details = "RealEstateLists.php?type=search&suburb=$sub&bedroom=$bedroom&bathroom=$bathroom"; $search_details .= "&saleprice=$saleprice&search_region=$reg&prop_type=$p_type"; $search_details .= "&sORr=$sORr&ag=$ag&cORg=$cORg"; $userid = substr($email_address, 0, strlen($email_address)-strlen (strstr ($email_address,'@'))); $state = substr($search_region, 0, strlen($search_region)-strlen (strstr ($search_region,'-'))); if ($howlong == 0) { $dt = mktime (0,0,0,date("m") ,date("d")+7,date("Y")); } else { $dt = mktime (0,0,0,date("m")+$howlong ,date("d") ,date("Y")); } $day = date ("d",$dt); $mon = date ("m",$dt); $year = date ("Y",$dt); $expiry_date = $year .'-'.$mon.'-'.$day; $html_expiry_date = $day .'/'.$mon.'/'.$year; $headers = "From: property@global-online.com.au\n"; $body = "UserID = $userid\n"; $body .= "Email = $email_address\n"; $body .= "Daily = $daily\n"; $body .= "All_Properties = $all_properties\n"; $body .= "How Long = $howlong\n"; $body .= "State = $state\n"; $body .= "Region = $search_region\n"; $body .= "Suburb = $suburb\n"; $body .= "PropertyType = $prop_type\n"; $body .= "PriceTo = $saleprice\n"; $body .= "NumBedrooms = $bedroom\n"; $body .= "NumBathrooms = $bathroom\n"; $body .= "Agent = $ag\n"; $body .= "Sales_or_Rental = $sORr\n"; $body .= "Client_or_Group = $cORg\n"; $body .= "ExpiryDate = $expiry_date\n"; $body .= "Cancel = $cancel\n"; mail("cs@global-online.com.au", "Real Estate - email alert registration", $body, $headers); $sql = "SELECT UserID FROM EmailAdviser Where Email = '$email_address'"; $res = mysql_query($sql,$link); if (mysql_num_rows($res) > 0 ) { if ($cancel) { $sql = "DELETE FROM EmailAdviser "; $sql .= "Where Email = '$email_address'"; $result = mysql_query($sql,$link); if ($result) { header ("refresh: 2; url=RealEstateAdviser.php?ag=$ag&sORr=$sORr&cORg=$cORg"); processingPage("
  • Your e-mail adviser settings have been deleted from our database"); exit(); } else { errorPage("
  • An unknown error has happened, please try again
    if the error persist contact Global Online Marketing
    " . mysql_error()); exit(); } } // append the retrieved information to the database $sql = "UPDATE EmailAdviser SET "; $sql .= "UserID = '$userid', "; $sql .= "Email = '$email_address', "; $sql .= "Daily = '$daily', "; $sql .= "All_Properties = '$all_properties', "; $sql .= "State = '$state', "; $sql .= "Region = '$search_region', "; $sql .= "Suburb = '$suburb', "; $sql .= "PropertyType = '$prop_type', "; $sql .= "PriceTo = '$saleprice', "; $sql .= "NumBedrooms = '$bedroom', "; $sql .= "NumBathrooms = '$bathroom', "; $sql .= "Agent = '$ag', "; $sql .= "Sales_or_Rental = '$sORr', "; $sql .= "Client_or_Group = '$cORg', "; $sql .= "ExpiryDate = '$expiry_date' Where Email = '$email_address'"; $result = mysql_query($sql,$link); if ($result) { header ("refresh: 2; url=$search_details"); processingPage("
  • Your e-mail adviser settings have been updated on our database
    and it will expire at $html_expiry_date"); exit(); } else { errorPage("
  • An unknown error has happened, please try again
    if the error persist contact Global Online Marketing
    " . mysql_error()); exit(); } } else { // append the retrieved information to the database $sql = "INSERT INTO EmailAdviser SET "; $sql .= "UserID = '$userid', "; $sql .= "Email = '$email_address', "; $sql .= "Daily = '$daily', "; $sql .= "All_Properties = '$all_properties', "; $sql .= "State = '$state', "; $sql .= "Region = '$search_region', "; $sql .= "Suburb = '$suburb', "; $sql .= "PropertyType = '$prop_type', "; $sql .= "PriceTo = '$saleprice', "; $sql .= "NumBedrooms = '$bedroom', "; $sql .= "NumBathrooms = '$bathroom', "; $sql .= "Agent = '$ag', "; $sql .= "Sales_or_Rental = '$sORr', "; $sql .= "Client_or_Group = '$cORg', "; $sql .= "ExpiryDate = '$expiry_date'"; $result = mysql_query($sql,$link); if ($result) { header ("refresh: 2; url=$search_details"); processingPage("
  • Your e-mail adviser settings have been added to our database
    and it will expire at $html_expiry_date"); exit(); } else { errorPage("
  • An unknown error has happened, please try again
    if the error persist contact Global Online Marketing
    " . mysql_error()); exit(); } } mysql_close($link); exit(); } else { header ("refresh: 2; url=RealEstateLists.php?type=full&sORr=$sORr&ag=$ag&cORg=$cORg"); errorPage("
  • An unknown error has happened, please try again
    if the error persist contact Global Online Marketing"); exit(); } exit; ?>