0){ while($row = mysql_fetch_array( $result0 )){ if($row['MLS'] != ""){ $MLS = $row['MLS']; $PtypeA = $row['PtypeA']; $PtypeB = $row['PtypeB']; $Province = $row['Province']; $City = $row['City']; $Area = $row['Area']; $Municipality = $row['Municipality']; $Community = $row['Community']; $Paddress = $row['Paddress']; $Paddress2 = $row['Paddress2']; $Intersection = $row['Intersection']; $Intersection = preg_replace('/\//i', '-', $Intersection); $Intersection = preg_replace('/\s+/i', '-', $Intersection); $Intersection = preg_replace('/,/i', '-', $Intersection); $Intersection = preg_replace('/\./i', '-', $Intersection); $Intersection = preg_replace('/:/i', '-', $Intersection); $PaddressTitle = preg_replace('/^\s+/i', '', $Paddress); $PaddressTitle = preg_replace('/\s+$/i', '', $PaddressTitle); $PaddressTitle = preg_replace('/\d+$/i', '', $PaddressTitle); $PaddressTitle = preg_replace('/\s+/i', '-', $PaddressTitle); $PaddressTitle = preg_replace('/,/i', '-', $PaddressTitle); $PaddressTitle = preg_replace('/\./i', '-', $PaddressTitle); $PaddressTitle = preg_replace('/:/i', '-', $PaddressTitle); if($PtypeA == 'Condo Apt'){ if($Municipality != "" and $Community != ""){ $AreaTitle = $City.'-Condo-'.$Municipality.'-'.$Community; }else{ $AreaTitle = $City.'-Condo'; } }else{ if($Municipality != "" and $Community != ""){ $AreaTitle = $City.'-House'; }else{ $AreaTitle = $City.'-House'; } } $AreaTitle = preg_replace('/\s+/i', '-', $AreaTitle); $AreaTitle = preg_replace('/,/i', '-', $AreaTitle); $AreaTitle = preg_replace('/\./i', '-', $AreaTitle); $AreaTitle = preg_replace('/:/i', '-', $AreaTitle); $tmpLinkString = $AreaTitle."-".$PaddressTitle."-".$Intersection; return $tmpLinkString; //echo 'http://www.leozhang.ca/mls-'.$row['MLS']."-".$AreaTitle."-".$PaddressTitle."-".$Intersection."
\n"; } } } } function GetHomeOwlSelectionString (){ $display_html = ''; return $display_html; } function Text2Link ($text){ //$anchortxt['��']='��'; //$anchortxt['��']='��'; $text = str_replace('��', '��', $text); $text = str_replace('��', '��', $text); $text = str_replace('�ⷿ', '�ⷿ', $text); return $text; } function GetArticleInfoByID ($id){ $query = "SELECT * FROM leo_articles where id = $id"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetUserIDByLeadID ($id){ $query = "SELECT * FROM 51ca_whoisonline_s where id = $id"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetPropertyInfoByPID ($pid){ $query = "SELECT * FROM 51jj_properties where id = $pid"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetTouchBaseShowingNumberByMLS ($link,$MLS){ $sql = "SELECT AgentName FROM rentbee_deals_touchbase where active = 'Y' and MLS = '".$MLS."'"; if($result = mysqli_query($link, $sql)){ if(mysqli_num_rows($result) > 0){ $check = mysqli_num_rows($result); mysqli_free_result($result); return $check; } else{ echo ""; } } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } } function GetInfoFromRentBeeDealsByMLS ($link,$MLS){ $sql = "SELECT * FROM rentbee_deals where stage = 0 and MLS = '".$MLS."' limit 1"; if($result = mysqli_query($link, $sql)){ if(mysqli_num_rows($result) > 0){ $row = mysqli_fetch_array($result); mysqli_free_result($result); return $row; } else{ echo ""; } } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } } function get_MLS_PhotoMaxNum ($link,$MLS){ $sql = "SELECT * FROM mls_imgmaxnum where MLS = '".$MLS."' limit 1"; if($result = mysqli_query($link, $sql)){ if(mysqli_num_rows($result) > 0){ $row = mysqli_fetch_array($result); mysqli_free_result($result); return $row; } else{ echo ""; } } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } } function get_MLS_Coordinates ($link,$MLS){ $sql = "SELECT * FROM mls_coordinates where MLS = '".$MLS."' limit 1"; if($result = mysqli_query($link, $sql)){ if(mysqli_num_rows($result) > 0){ $row = mysqli_fetch_array($result); mysqli_free_result($result); return $row; } else{ echo ""; } } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } } function get_LeoUserinfoNew ($link,$id){ $sql = "SELECT * FROM leo_clients where id = ".$id." limit 1"; if($result = mysqli_query($link, $sql)){ if(mysqli_num_rows($result) > 0){ $row = mysqli_fetch_array($result); mysqli_free_result($result); return $row; } else{ echo ""; } } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } } function GetFreeActivePropertyInfoByMLS ($link,$MLS){ $sql = "SELECT * FROM wisedeal_mls_data_free_active where MLS = '".$MLS."' limit 1"; if($result = mysqli_query($link, $sql)){ if(mysqli_num_rows($result) > 0){ $row = mysqli_fetch_array($result); mysqli_free_result($result); return $row; } else{ echo ""; } } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } } function GetCondoActivePropertyInfoByMLS ($link,$MLS){ $sql = "SELECT * FROM wisedeal_mls_data_condo_active where MLS = '".$MLS."' limit 1"; if($result = mysqli_query($link, $sql)){ if(mysqli_num_rows($result) > 0){ $row = mysqli_fetch_array($result); mysqli_free_result($result); return $row; } else{ echo ""; } } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } } function GetFreeArchivePropertyInfoByMLS ($link,$MLS){ $sql = "SELECT * FROM wisedeal_mls_data_free_archive where MLS = '".$MLS."' limit 1"; if($result = mysqli_query($link, $sql)){ if(mysqli_num_rows($result) > 0){ $row = mysqli_fetch_array($result); mysqli_free_result($result); return $row; } else{ echo ""; } } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } } function GetCondoArchivePropertyInfoByMLS ($link,$MLS){ $sql = "SELECT * FROM wisedeal_mls_data_condo_archive where MLS = '".$MLS."' limit 1"; if($result = mysqli_query($link, $sql)){ if(mysqli_num_rows($result) > 0){ $row = mysqli_fetch_array($result); mysqli_free_result($result); return $row; } else{ echo ""; } } else{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($link); } } function GetUniversalPropertyInfoByMLS ($link,$mls){ $row = GetFreeActivePropertyInfoByMLS($link,$mls); if($row == ''){ $row = GetCondoActivePropertyInfoByMLS($link,$mls); }else{ return $row; } if($row == ''){ $row = GetFreeArchivePropertyInfoByMLS($link,$mls); }else{ return $row; } if($row == ''){ $row = GetCondoArchivePropertyInfoByMLS($link,$mls);} return $row; } function GetSimilarPropertiesByMLS ($mls,$num){ $row001 = GetPropertyInfoByMLS($mls); $PostalCode = $row001['PostalCode']; $PtypeA = $row001['PtypeA']; $AskingPrice = $row001['AskingPrice']; $AskingPrice_1 = $AskingPrice - 50000; $AskingPrice_2 = $AskingPrice + 50000; $myPostalCode = substr($PostalCode, 0, 3); $query001 = "SELECT * FROM 51jj_properties where PostalCode like '".$myPostalCode."%' and PtypeA = '".$PtypeA."' and AskingPrice > ".$AskingPrice_1." and AskingPrice < ".$AskingPrice_2." and MLS <> '".$mls."' order by id DESC limit ".$num; $result001 = MYSQL_QUERY($query001); while($row1 = mysql_fetch_array( $result001 )){ $pid = $row1['id']; $row = GetPropertyInfoByPID($pid); $MLS = $row1['MLS']; $FMLS = MLS2FMLS($MLS); $PtypeA = $row1['PtypeA']; $PtypeB = $row1['PtypeB']; $Province = $row1['Province']; $Area = $row1['Area']; $Area000 = $row1['Area']; $City = $row1['City']; $City000 = $row1['City']; $Municipality = $row1['Municipality']; $Municipality000 = $row1['Municipality']; $Community = $row1['Community']; $Paddress = $row1['Paddress']; $Paddress2 = $row1['Paddress2']; $PaddressTitle = preg_replace('/\d+/i', '', $Paddress); $PaddressTitle = preg_replace('/\d+/i', '', $PaddressTitle); $PaddressTitle = preg_replace('/^\s+/i', '', $PaddressTitle); $PaddressTitle = preg_replace('/\s+$/i', '', $PaddressTitle); $PostalCode = $row['PostalCode']; $PLatitude = $row['PLatitude']; $PLongitude = $row['PLongitude']; $LastStatus = $row1['LastStatus']; $AskingPrice = $row1['AskingPrice']; $ContactDate = $row1['ContactDate']; $RealDOM_tmp = strtotime(date("Y-M-d")) - (strtotime($ContactDate)); $RealDOM = floor($RealDOM_tmp/3600/24); $ExpiryDate = $row1['ExpiryDate']; $LastUpdate = $row1['LastUpdate']; $SoldDate = $row1['SoldDate']; $ClosingDate = $row1['ClosingDate']; $TrebArea = $row1['TrebArea']; $DOM = $row1['DOM']; $Taxes = $row1['Taxes']; $PriceSold = $row1['PriceSold']; $PriceList = $row1['PriceList']; $Intersection = $row1['Intersection']; $Seller = $row1['Seller']; $Occup = $row1['Occup']; $Possession = $row1['Possession']; $Rooms = $row1['Rooms']; $Bedrooms = $row1['Bedrooms']; $BedroomsPlus = $row1['BedroomsPlus']; $Washrooms = $row1['Washrooms']; $Kitchens = $row1['Kitchens']; $Familyrooms = $row1['Familyrooms']; $Basement = $row1['Basement']; $Apxage = $row1['Apxage']; $ApxSqft = $row1['ApxSqft']; $Exposure = $row1['Exposure']; $Maint = $row1['Maint']; $Pool = $row1['Pool']; $ExerciseRm = $row1['ExerciseRm']; $Locker = $row1['Locker']; $RecRoom = $row1['RecRoom']; $Sauna = $row1['Sauna']; $Security = $row1['Security']; $Squash = $row1['Squash']; $Tennis = $row1['Tennis']; $HeatIncl = $row1['HeatIncl']; $HydroIncl = $row1['HydroIncl']; $WaterIncl = $row['WaterIncl']; $TaxesIncl = $row['TaxesIncl']; $CableTVIncl = $row['CableTVIncl']; $CACIncl = $row['CACIncl']; $BldgInsurIncl = $row['BldgInsurIncl']; $ParkingIncl = $row['ParkingIncl']; $Fulldescription = $row['Fulldescription']; $Fulldescription = preg_replace('/Remarks for Brokerages:.*/i','',$Fulldescription); $Fulldescription = preg_replace('/Remarks For Clients: /i','',$Fulldescription); $Fulldescription = preg_replace('/~q~/i','\'',$Fulldescription); $Fulldescription = preg_replace('/~qq~/i','\"',$Fulldescription); $FulldescriptionShort = substr($Fulldescription, 0, 320); $theimages = preg_split("/\|/i", $row['Photos'],-1 , PREG_SPLIT_NO_EMPTY); $countImages = count($theimages); $MainImage = $theimages[0]; if($MainImage == ''){ $last3string = substr($MLS, -3); $MainImage = "http://v3.torontomls.net/Live/photos/FULL/1/".$last3string."/".$MLS.".jpg"; } $items[] = array(1 => $MLS, 2 => $MainImage, 3 => $RealDOM, 4 => $FMLS, 5 => $AskingPrice, 6 => $Bedrooms, 7 => $BedroomsPlus, 8 => $Washrooms, 9 => $PtypeA, 10 => $PtypeB, 11 => $PaddressTitle, 12 => $Community, 13 => $Municipality, 14 => $Area, 15 => $Province, 16 => $FulldescriptionShort, 17 => $Intersection); } return $items; } function GetOldPropertyInfoByPID ($pid){ $query = "SELECT * FROM wisedeal_properties_all where id = $pid"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetPropertyInfoSOLDByPID ($pid){ $query = "SELECT * FROM 51jj_properties_sold where id = $pid"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetPropertyInfoByPID_biz ($pid){ $query = "SELECT * FROM 51jj_properties_biz where id = $pid"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetCondoDBInfoByID ($id){ $query = "SELECT * FROM leo_condo_db where id = $id"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetLeoTeamInfoByID ($id){ $query = "SELECT * FROM leo_team where id = $id"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetLeoTeamInfoByCODE ($code){ $query = "SELECT * FROM leo_team where code = '".$code."'"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetPropertyInfoBIZByMLS ($mls){ $query = "SELECT * FROM 51jj_properties_biz where MLS = '".$mls."'"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetPropertyInfoByMLS ($mls){ //$query = "SELECT * FROM 51jj_properties where MLS = '".$mls."'"; $query = "SELECT * FROM wisedeal_properties where MLS = '".$mls."'"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetPropertyInfoAllByMLS ($mls){ $query = "SELECT * FROM wisedeal_properties_all where MLS = '".$mls."'"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetPrettyURLByMLS ($link,$mymls){ $row = GetFreeActivePropertyInfoByMLS($link,$mymls); if($row == ''){ $row = GetCondoActivePropertyInfoByMLS($link,$mymls); } if($row == ''){ $row = GetFreeArchivePropertyInfoByMLS($link,$mymls); } if($row == ''){ $row = GetCondoArchivePropertyInfoByMLS($link,$mymls); } $Addr = $row['addr']; $Addr = preg_replace("/[\s_]/", "-", $Addr); $Addr = preg_replace("/\&/", "~n~", $Addr); $Municipality = $row['municipality']; $Municipality = preg_replace("/[\s_]/", "-", $Municipality); $Community = $row['community']; $Community = preg_replace("/[\s_]/", "-", $Community); $prettyURL = 'http://www.housefox.ca/'.$mymls.'-'.$Addr.'-'.$Municipality.'-'.$Community; return $prettyURL; } function GetTotalRentalNum (){ // $query = "SELECT count(*) as total FROM wisedeal_properties where (LastStatus = 'A' or LastStatus = 'New' or LastStatus = 'Pc') and AskingPrice > 1000 and AskingPrice < 100000 and ContactDate > '2015-07-01'"; // $query = "SELECT count(*) as total FROM wisedeal_properties where LastStatus = 'AA' and AskingPrice > 1000 and AskingPrice < 100000 and ContactDate > '2016-01-01'"; $query = "SELECT count(*) as total FROM wisedeal_properties where AskingPrice > 1000 and AskingPrice < 100000"; $result = MYSQL_QUERY($query); return mysql_result($result, 0); } function GetTotalShortRentalNum (){ $query = "SELECT count(*) as total FROM wisedeal_lease_properties"; $result = MYSQL_QUERY($query); return mysql_result($result, 0); } function GetSchoolInfoByID ($sid){ $query = "SELECT * FROM leo_school_db where SchoolNumber = '".$sid."'"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetPropertyInfoFullByMLS ($mls){ $query = "SELECT * FROM wisedeal_properties where MLS = '".$mls."'"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetPropertyInfoOldByMLS ($mls){ $query = "SELECT * FROM wisedeal_properties_all where MLS = '".$mls."'"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetPropertyMainInfoByMLS ($mls){ $query = "SELECT * FROM 51jj_properties_main where MLS = '".$mls."'"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetOldPropertyInfoByMLS ($mls){ $query = "SELECT * FROM wisedeal_properties_all where MLS = '".$mls."'"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetPropertyInfoSOLDByMLS ($mls){ $query = "SELECT * FROM 51jj_properties_sold where MLS = '".$mls."'"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetPropertyInfoByMLS_biz ($mls){ $query = "SELECT * FROM 51jj_properties_biz where MLS = '".$mls."'"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetLastLeoClientLogEntryByCID ($cid){ $query = "SELECT * FROM leo_client_logs where cid = ".$cid." order by log_date DESC limit 1"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetPropertyBulkInfoByMLS ($mls){ $query = "SELECT * FROM 51jj_properties_bulk where MLS = '".$mls."'"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetNewlyUpdatedNumber (){ $today = date("Y-m-d"); $query = "SELECT count(*) as MYCOUNT FROM 51jj_properties where ContactDate = SUBDATE(CURDATE(), INTERVAL 1 DAY)"; $result = MYSQL_QUERY($query); if (!$result) { // echo 'Could not run query: ' . mysql_error(); // exit; return "0"; }else{ while($row = mysql_fetch_array($result)){ return $row['MYCOUNT']; } } } function GetAlertNumByAgentName ($name){ $myC = 0; $today = date("Y-m-d"); $query001 = "SELECT * FROM leo_clients where (aim like '%BUY%' or aim like '&Inquiry&') and active = 'Y' and rating > -1 and rating < 100 and misc ='".$name."' order by rating DESC"; //print $query001; $result001 = MYSQL_QUERY($query001); $number001 = MYSQL_NUMROWS($result001); while($row001 = mysql_fetch_array( $result001 )){ $HoursNotFollowed = 0;$alertDisp=''; $cid = $row001['id']; $GetLastLeoClientLogEntryByCID = GetLastLeoClientLogEntryByCID($cid); $hourstoalert = $row001['hourstoalert']; if(!$hourstoalert) { $hourstoalert = 48; } if($GetLastLeoClientLogEntryByCID){ $LastModifiedDatetime = $GetLastLeoClientLogEntryByCID['log_date']; $now = date('Y-m-d H:i:s',time()); $HoursNotFollowed = datediff('h', $LastModifiedDatetime, $now, false); if($HoursNotFollowed > $hourstoalert && $rating < 100){ $myC++; //$alertDisp = ''; } }else{ $HoursNotFollowed = -1; } } return $myC; } function MLS2FMLS ($mls){ $fmls_tmp = $mls; $fmls_tmp_A = preg_replace('/^\w/','',$fmls_tmp); $fmls_tmp_A = $fmls_tmp_A + 2188888; $fmls_tmp_B = preg_replace('/\d+$/','',$fmls_tmp); $fmls = $fmls_tmp_B.$fmls_tmp_A; return $fmls; } function E2C ($desc){ $desc_tmp = $desc; $desc_tmp = preg_replace('/Remarks For Clients:/i','',$desc_tmp); $desc_tmp = preg_replace('/Remarks For Brokerages:.*/i','',$desc_tmp); $desc_tmp = preg_replace('/Extras:/i','
�۸����: ',$desc_tmp); $desc_tmp = preg_replace('/Very Convenient Location/i','�dz�����ĵص�',$desc_tmp); $desc_tmp = preg_replace('/Steps To Ttc/i','��TTC',$desc_tmp); $desc_tmp = preg_replace('/Restaurants/i','��͹�',$desc_tmp); $desc_tmp = preg_replace('/Schools/i','��ѧУ',$desc_tmp); $desc_tmp = preg_replace('/New Windows/i','�´���',$desc_tmp); $desc_tmp = preg_replace('/New Kitchen/i','�³�',$desc_tmp); $desc_tmp = preg_replace('/Quiet Neighbourhood/i','����������',$desc_tmp); $desc_tmp = preg_replace('/Quality Built Detached Home/i','���������������',$desc_tmp); $desc_tmp = preg_replace('/Shopping Mall/i','��������',$desc_tmp); $desc_tmp = preg_replace('/Ttc/i','��',$desc_tmp); $desc_tmp = preg_replace('/Amenities/i','����ʩ',$desc_tmp); $desc_tmp = preg_replace('/Fridge/i','�����',$desc_tmp); $desc_tmp = preg_replace('/Stove/i','��¯��',$desc_tmp); $desc_tmp = preg_replace('/Dishwasher/i','��ϴ���',$desc_tmp); $desc_tmp = preg_replace('/Washer/i','��ϴ�»�',$desc_tmp); $desc_tmp = preg_replace('/Dryer/i','���ɻ�',$desc_tmp); $desc_tmp = preg_replace('/All Window Coverings/i','�����еĴ��',$desc_tmp); $desc_tmp = preg_replace('/All Electrical Lighting Fixtures/i','�����еĵ���',$desc_tmp); $desc_tmp = preg_replace('/Professional Landscaping/i','רҵ԰��',$desc_tmp); return $desc_tmp; } function FMLS2MLS ($mls){ $fmls_tmp = $mls; $fmls_tmp_A = preg_replace('/^\w/','',$fmls_tmp); $fmls_tmp_A = $fmls_tmp_A - 2188888; $fmls_tmp_B = preg_replace('/\d+$/','',$fmls_tmp); $fmls = $fmls_tmp_B.$fmls_tmp_A; return $fmls; } function PurifyEXP ($exp){ $exp_tmp = preg_replace('/\s\w+$/','',$exp); //$theE = preg_split( '/\s+/', $s,-1, PREG_SPLIT_NO_EMPTY ); return $exp_tmp; } function HideAddr ($addr){ $addr_tmp = preg_replace('/\d$/','X',$addr); //$theE = preg_split( '/\s+/', $s,-1, PREG_SPLIT_NO_EMPTY ); return $addr_tmp; } function GetInfoByDESP ($desp){ $tmpitems = preg_split( '/<\/tr>/', $desp,-1, PREG_SPLIT_NO_EMPTY ); foreach ($tmpitems as $tmpVALUE) { //return $tmpVALUE; if (preg_match("/Living/", $tmpVALUE)){ $tmpitemA = preg_split( '/<\/td>/', $tmpVALUE,-1, PREG_SPLIT_NO_EMPTY ); //return $tmpitemA[1]."=>".$tmpitemA[2]."=>".$tmpitemA[3]; if(preg_match("/Living/", $tmpitemA[1])){ if(preg_match("/x/i", striping_string($tmpitemA[4]))){ $tmpAreaLiving = striping_string($tmpitemA[3]) * striping_string($tmpitemA[5]); } } if(preg_match("/Hardwood/", $tmpitemA[7]) || preg_match("/Hardwood/", $tmpitemA[8]) || preg_match("/Hardwood/", $tmpitemA[9])){ $tmpAreaLivingFloor = "Hardwood"; } if(preg_match("/Broadloom/", $tmpitemA[7]) || preg_match("/Broadloom/", $tmpitemA[8]) || preg_match("/Broadloom/", $tmpitemA[9])){ $tmpAreaLivingFloor = "Broadloom"; } if(preg_match("/Laminate/", $tmpitemA[7]) || preg_match("/Laminate/", $tmpitemA[8]) || preg_match("/Laminate/", $tmpitemA[9])){ $tmpAreaLivingFloor = "Laminate"; } } if (preg_match("/Master/", $tmpVALUE)){ $tmpitemA = preg_split( '/<\/td>/', $tmpVALUE,-1, PREG_SPLIT_NO_EMPTY ); //return $tmpitemA[1]."=>".$tmpitemA[2]."=>".$tmpitemA[3]; if(preg_match("/Master/", $tmpitemA[1])){ if(preg_match("/x/i", striping_string($tmpitemA[4]))){ $tmpAreaMaster = striping_string($tmpitemA[3]) * striping_string($tmpitemA[5]); } } } } return $tmpAreaLiving."|".$tmpAreaLivingFloor."|".$tmpAreaMaster; } function striping_string ($tmp) { $tmp = preg_replace( "/<.[^>]*>/", '', $tmp ); $tmp = preg_replace( "/^\s+/", '', $tmp ); $tmp = preg_replace( "/\s+$/", '', $tmp ); $tmp = preg_replace( "/[=~]/", '', $tmp ); $tmp = preg_replace( "/\s+/", '', $tmp ); $tmp = preg_replace( "/ \;/", '', $tmp ); return $tmp; } function striping_string1 ($tmp) { $tmp = preg_replace( "/<.[^>]*>/", '', $tmp ); $tmp = preg_replace( "/^\s+/", '', $tmp ); $tmp = preg_replace( "/\s+$/", '', $tmp ); $tmp = preg_replace( "/[=~]/", '', $tmp ); //$tmp = preg_replace( "/\s+/", '', $tmp ); $tmp = preg_replace( "/ \;/", '', $tmp ); return $tmp; } function get_LeoUserinfo ($id){ $query = "SELECT * FROM leo_clients where id=".$id; $result = MYSQL_QUERY($query); $number = MYSQL_NUMROWS($result); if($number>0){ $row = mysql_fetch_array( $result ); return $row; }else{ return null; } } function get_LeoTeamInfoByUser ($user){ $query = "SELECT * FROM leo_team where username='".$user."'"; $result = MYSQL_QUERY($query); $number = MYSQL_NUMROWS($result); if($number>0){ $row = mysql_fetch_array( $result ); return $row; }else{ return null; } } function get_ClientDealNumByName ($name){ $query = "SELECT count(*) as C FROM leo_clients where misc = '".$name."' and rating >= 100"; $result = MYSQL_QUERY($query); $number = MYSQL_NUMROWS($result); if($number>0){ $row = mysql_fetch_array( $result ); return $row['C']; }else{ return 0; } } function get_LeoTeamUserinfo ($id){ $query = "SELECT * FROM leo_team where id=".$id; $result = MYSQL_QUERY($query); $number = MYSQL_NUMROWS($result); if($number>0){ $row = mysql_fetch_array( $result ); return $row; }else{ return null; } } function get_LeoUserinfoByEmail ($email){ $query = "SELECT * FROM leo_clients where email = '".$email."'"; $result = MYSQL_QUERY($query); $number = MYSQL_NUMROWS($result); if($number>0){ $row = mysql_fetch_array( $result ); return $row; }else{ return null; } } function get_SaveSearchInfo ($id){ $query = "SELECT * FROM leo_clients_savesearch where id=".$id; $result = MYSQL_QUERY($query); $number = MYSQL_NUMROWS($result); if($number>0){ $row = mysql_fetch_array( $result ); return $row; }else{ return null; } } function get_ST_Elementary_BySchool ($id){ $query = "SELECT * FROM leo_school_maps where Elementary='".$id."'"; $result = MYSQL_QUERY($query); $number = MYSQL_NUMROWS($result); if($number>0){ $row = mysql_fetch_array( $result ); return $row; }else{ return null; } } function get_ST_Intermediate_BySchool ($id){ $query = "SELECT * FROM leo_school_maps where Intermediate='".$id."'"; $result = MYSQL_QUERY($query); $number = MYSQL_NUMROWS($result); if($number>0){ $row = mysql_fetch_array( $result ); return $row; }else{ return null; } } function get_ST_Secondary_BySchool ($id){ $query = "SELECT * FROM leo_school_maps where Secondary='".$id."'"; $result = MYSQL_QUERY($query); $number = MYSQL_NUMROWS($result); if($number>0){ $row = mysql_fetch_array( $result ); return $row; }else{ return null; } } function get_CondoSharkUserinfo ($id){ $query = "SELECT * FROM condoshark_clients where id=".$id; $result = MYSQL_QUERY($query); $number = MYSQL_NUMROWS($result); if($number>0){ $row = mysql_fetch_array( $result ); return $row; }else{ return null; } } function get_CondoSharkTeamAgentinfo ($id){ $query = "SELECT * FROM condoshark_team_agents where id=".$id; $result = MYSQL_QUERY($query); $number = MYSQL_NUMROWS($result); if($number>0){ $row = mysql_fetch_array( $result ); return $row; }else{ return null; } } function get_LeoSSinfo ($id){ $query = "SELECT * FROM leo_clients_savesearch where cid=".$id; $result = MYSQL_QUERY($query); $number = MYSQL_NUMROWS($result); if($number>0){ $row = mysql_fetch_array( $result ); return $row; }else{ return null; } } function get_SteetNameByFull ($stname){ $stname = preg_replace('/^\d+\s/', '', $stname); $stname = preg_replace('/\s\d+$/', '', $stname); return $stname; } function get_MapSteetNameByFull ($stname){ #$stname = preg_replace('/^\d+\s/', '', $stname); $stname = preg_replace('/\s\d+$/', '', $stname); return $stname; } function get_LeoSchoolBySteetName ($stname){ //$query = "SELECT * FROM leo_school_maps where streetname = '".$stname."' and range like '%All Numbers%'"; $query = "SELECT * FROM leo_school_maps where streetname = '".$stname."'"; //echo $query; $result = MYSQL_QUERY($query); //echo mysql_error(); $number = MYSQL_NUMROWS($result); if($number>0){ $row = mysql_fetch_array( $result ); $Elementary = $row['Elementary']; $Intermediate = $row['Intermediate']; $Secondary = $row['Secondary']; $BT = $row['BT']; $High = $row['High']; $schoolinfo = array($Elementary,$Intermediate,$Secondary,$BT,$High); return $schoolinfo; }else{ /* $query1 = "SELECT * FROM leo_school_maps where streetname='".$stname."' and range like '%Odd%'"; $result1 = MYSQL_QUERY($query1); $number1 = MYSQL_NUMROWS($result1); if($number1>0){ $row1 = mysql_fetch_array( $result1 ); $Elementary = $row1['Elementary']; $Intermediate = $row1['Intermediate']; $Secondary = $row1['Secondary']; $BT = $row1['BT']; $High = $row1['High']; $schoolinfo = array($Elementary,$Intermediate,$Secondary,$BT,$High); return $schoolinfo; }else{ } */ return null; } } function resampimagejpg ($forcedwidth, $forcedheight, $sourcefile, $destfile, $imgcomp) { $g_imgcomp=100-$imgcomp; $g_srcfile=$sourcefile; $g_dstfile=$destfile; $g_fw=$forcedwidth; $g_fh=$forcedheight; if(file_exists($g_srcfile)) { $g_is=getimagesize($g_srcfile); if(($g_is[0]-$g_fw)>=($g_is[1]-$g_fh)) { $g_iw=$g_fw; $g_ih=($g_fw/$g_is[0])*$g_is[1]; } else { $g_ih=$g_fh; $g_iw=($g_ih/$g_is[1])*$g_is[0]; } $img_src=imagecreatefromjpeg($g_srcfile); $img_dst=imagecreate($g_iw,$g_ih); imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $g_iw, $g_ih, $g_is[0], $g_is[1]); imagejpeg($img_dst, $g_dstfile, $g_imgcomp); imagedestroy($img_dst); return true; } else return false; } function get_username ($id){ $query = "SELECT username FROM i4cc_users where id=".$id; $result = MYSQL_QUERY($query); $number = MYSQL_NUMROWS($result); if($number>0){ $row = mysql_fetch_array( $result ); return $row['username']; }else{ return ""; } } function get_ClientTotalNum (){ $query = "SELECT count(*) as C FROM leo_clients"; $result = MYSQL_QUERY($query); $number = MYSQL_NUMROWS($result); if($number>0){ $row = mysql_fetch_array( $result ); return $row['C']; }else{ return 0; } } function get_realname ($id){ $query = "SELECT realname FROM i4cc_users where id=".$id; $result = MYSQL_QUERY($query); $number = MYSQL_NUMROWS($result); if($number>0){ $row = mysql_fetch_array( $result ); return $row['realname']; }else{ return ""; } } function get_nickname ($id){ $query = "SELECT nickname FROM i4cc_users where id=".$id; $result = MYSQL_QUERY($query); $number = MYSQL_NUMROWS($result); if($number>0){ $row = mysql_fetch_array( $result ); return $row['nickname']; }else{ return ""; } } function get_usertype ($id){ $query = "SELECT type FROM love_users where id=".$id; $result = MYSQL_QUERY($query); $number = MYSQL_NUMROWS($result); if($number>0){ $row = mysql_fetch_array( $result ); return $row['type']; }else{ return ""; } } function get_mainimage_url_by_mls ($mls){ $last3string = substr($mls, -3); $theimages = "http://v3.torontomls.net/Live/photos/FULL/1/".$last3string."/".$mls.".jpg"; return $theimages; } function get_category_by_adid ($id){ $query = "SELECT category FROM i4cc_classifieds where id=".$id; $result = MYSQL_QUERY($query); $number = MYSQL_NUMROWS($result); if($number>0){ $row = mysql_fetch_array( $result ); return $row['category']; }else{ return ""; } } function get_searchable ($id){ $query = "SELECT searchable FROM love_users where id=".$id; $result = MYSQL_QUERY($query); $number = MYSQL_NUMROWS($result); if($number>0){ $row = mysql_fetch_array( $result ); return $row['searchable']; }else{ return ""; } } function is_odd($number) { return $number & 1; // 0 = even, 1 = odd } function get_catnum1($number) { $myfile = file_get_contents($number.'.txt'); if($myfile){ return $myfile; }else{ return "0"; } } function get_catnum($number,$locid) { $myfile = file_get_contents($number.'.txt'); $mypieces = explode("|", $myfile); if($myfile){ if($mypieces[$locid] != ""){ return $mypieces[$locid]; }else{ return "0"; } }else{ return "0"; } } function removeGridInURL($url) { $url = preg_replace('/&grid=/i', '', $url); $url = preg_replace('/&grid=Y/i', '', $url); $url = preg_replace('/&grid=N/i', '', $url); return $url; } function datediff($interval, $datefrom, $dateto, $using_timestamps = false) { /* $interval can be: yyyy - Number of full years q - Number of full quarters m - Number of full months y - Difference between day numbers (eg 1st Jan 2004 is "1", the first day. 2nd Feb 2003 is "33". The datediff is "-32".) d - Number of full days w - Number of full weekdays ww - Number of full weeks h - Number of full hours n - Number of full minutes s - Number of full seconds (default) */ # if (!$using_timestamps) { $datefrom = strtotime($datefrom, 0); $dateto = strtotime($dateto, 0); } $difference = $dateto - $datefrom; // Difference in seconds # switch($interval) { # case 'yyyy': // Number of full years $years_difference = floor($difference / 31536000); if (mktime(date("H", $datefrom), date("i", $datefrom), date("s", $datefrom), date("n", $datefrom), date("j", $datefrom), date("Y", $datefrom)+$years_difference) > $dateto) { $years_difference--; } if (mktime(date("H", $dateto), date("i", $dateto), date("s", $dateto), date("n", $dateto), date("j", $dateto), date("Y", $dateto)-($years_difference+1)) > $datefrom) { $years_difference++; } $datediff = $years_difference; break; case "q": // Number of full quarters $quarters_difference = floor($difference / 8035200); while (mktime(date("H", $datefrom), date("i", $datefrom), date("s", $datefrom), date("n", $datefrom)+($quarters_difference*3), date("j", $dateto), date("Y", $datefrom)) < $dateto) { $months_difference++; } $quarters_difference--; $datediff = $quarters_difference; break; case "m": // Number of full months $months_difference = floor($difference / 2678400); while (mktime(date("H", $datefrom), date("i", $datefrom), date("s", $datefrom), date("n", $datefrom)+($months_difference), date("j", $dateto), date("Y", $datefrom)) < $dateto) { $months_difference++; } $months_difference--; $datediff = $months_difference; break; case 'y': // Difference between day numbers $datediff = date("z", $dateto) - date("z", $datefrom); break; case "d": // Number of full days $datediff = floor($difference / 86400); break; case "w": // Number of full weekdays $days_difference = floor($difference / 86400); $weeks_difference = floor($days_difference / 7); // Complete weeks $first_day = date("w", $datefrom); $days_remainder = floor($days_difference % 7); $odd_days = $first_day + $days_remainder; // Do we have a Saturday or Sunday in the remainder? if ($odd_days > 7) { // Sunday $days_remainder--; } if ($odd_days > 6) { // Saturday $days_remainder--; } $datediff = ($weeks_difference * 5) + $days_remainder; break; case "ww": // Number of full weeks $datediff = floor($difference / 604800); break; case "h": // Number of full hours $datediff = floor($difference / 3600); break; case "n": // Number of full minutes $datediff = floor($difference / 60); break; default: // Number of full seconds (default) $datediff = $difference; break; } return $datediff; } function get_content($url) { $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_HEADER, 0); ob_start(); curl_exec ($ch); curl_close ($ch); $string = ob_get_contents(); ob_end_clean(); return $string; } function geocode($address) { $address = urlencode($address); $url = 'http://maps.googleapis.com/maps/api/geocode/xml?address='.$address.'&sensor=false'; $rawdata = get_data ($url); // print $rawdata;exit; $tmp1 = preg_split("/<\/location>/", $rawdata); $tmp2 = preg_split("//", $tmp1[0]); $data = $tmp1[1]; if(preg_match('/([^<]*)<\/lat>/i', $data, $match1)){ $lat = $match1[1]; } if(preg_match('/([^<]*)<\/lng>/i', $data, $match2)){ $lng = $match2[1]; } //echo "Longitude : ".$long; $coords = array('lat' => 0, 'lng' => 0); $coords['lat'] = $lat; $coords['lng'] = $lng; //$coords['lat'] = '43.849140'; //$coords['lng'] = '-79.432129'; return $coords; } // you can see another curl options at http://php.net/manual/en/function.curl-setopt.php function get_data($url) { $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false); curl_setopt($ch, CURLOPT_MAXREDIRS, 10); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $data = curl_exec($ch); curl_close($ch); return $data; } function geocode_old2($address) { $address = urlencode($address); $geocode = get_content ('http://where.yahooapis.com/geocode?q='.$address.'&appid=dj0yJmk9azI2VUFibEtkaFZHJmQ9WVdrOWFESkRTVlU1TjJVbWNHbzlNVGc1TkRrd01UWTJNZy0tJnM9Y29uc3VtZXJzZWNyZXQmeD0zMg--'); //$geocode = file_get_contents('http://where.yahooapis.com/geocode?q='.$address.'&appid=dj0yJmk9azI2VUFibEtkaFZHJmQ9WVdrOWFESkRTVlU1TjJVbWNHbzlNVGc1TkRrd01UWTJNZy0tJnM9Y29uc3VtZXJzZWNyZXQmeD0zMg--'); //echo $geocode;exit; preg_match('/([^<]*)<\/latitude>/', $geocode, $matches); $lat = $matches[1]; //print_r($matches);exit; preg_match('/([^<]*)<\/longitude>/', $geocode, $matches); $lng = $matches[1]; //echo "Longitude : ".$long; $coords = array('lat' => 0, 'lng' => 0); $coords['lat'] = $lat; $coords['lng'] = $lng; //$coords['lat'] = '43.849140'; //$coords['lng'] = '-79.432129'; return $coords; } function geocode_old1($address) { $address = urlencode($address); $geocode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$address.'&sensor=false'); $output= json_decode($geocode); $lat = $output->results[0]->geometry->location->lat; $long = $output->results[0]->geometry->location->lng; //echo "Latitude : ".$lat; //echo "Longitude : ".$long; $coords = array('lat' => 0, 'lng' => 0); $coords['lat'] = $lat; $coords['lng'] = $long; return $coords; } function geocode_old($address) { $address = urlencode($address); $url = "http://maps.google.com/maps/geo?output=xml&q=$address"; $coords = array('lat' => 0, 'lng' => 0); $delay = 0; $geocode_pending = true; // load file from url while($geocode_pending) { try { $xml = simplexml_load_file($url); } catch(Exception $e) { // return an empty array for a file request exception return array(); } //get response status $status = $xml->Response->Status->code; if (strcmp($status, '200') == 0) { $geocode_pending = false; // get coordinates node from xml response $coordsNode = explode(',', $xml->Response->Placemark->Point->coordinates); $coords['lat'] = $coordsNode[1]; $coords['lng'] = $coordsNode[0]; } // handle timeout responses and delay re-execution of geocoding else if (strcmp($status, 620) == 0) { $delay += 100000; } usleep($delay); } return $coords; } function GetCREAPropertyInfoByPID ($pid){ $query = "SELECT * FROM crea_properties_raw where pid = $pid"; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ return $row; } } } function GetLastCommentedAgentNameByCID ($cid){ $query = "SELECT log_name FROM leo_client_logs where cid = ".$cid." order by id DESC"; //print $query;exit; $result = MYSQL_QUERY($query); if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }else{ while($row = mysql_fetch_array($result)){ $LastCommentedAgentNameByCID = $row['log_name']; return $LastCommentedAgentNameByCID; } } } function GetClientTotalPointsByCID ($cid){ $query = "SELECT SUM(point) AS Total FROM leo_clients_points where cid = ".$cid; $result = MYSQL_QUERY($query); return mysql_result($result, 0); } function GetFollowUpCallsNumByAgent ($agentname,$days){ // $query = "SELECT count(*) as total FROM leo_client_followupcalls where agent = '".$agentname."' and ".'regdatetime <= NOW() AND regdatetime >= DATE_SUB(regdatetime, INTERVAL '.$days.' DAY)'; $query = "SELECT count(*) as total FROM leo_client_followupcalls where agent = '".$agentname."' and regdatetime > SUBDATE(NOW(), '".$days." day')"; $result = MYSQL_QUERY($query); return mysql_result($result, 0); } function GetPitchCallsNumByAgent ($agentname,$days){ // $query = "SELECT count(*) as total FROM leo_client_pitchcalls where agent = '".$agentname."' and ".'regdatetime <= NOW() AND regdatetime >= DATE_SUB(regdatetime, INTERVAL '.$days.' DAY)'; $query = "SELECT count(*) as total FROM leo_client_pitchcalls where agent = '".$agentname."' and regdatetime > SUBDATE(NOW(), '".$days." day')"; $result = MYSQL_QUERY($query); return mysql_result($result, 0); } function GetApptsNumOfCurrentMonthByAgent ($agentname){ $myYear = date('Y'); $myMonth = intval(date('m')); $query = "SELECT count(*) as total FROM leo_client_appts where agent = '".$agentname."' and ".'appt_year = '.$myYear.' and appt_month = '.$myMonth; $result = MYSQL_QUERY($query); return mysql_result($result, 0); } function GetApptsNumOfAllTimehByAgent ($agentname){ $query = "SELECT count(*) as total FROM leo_client_appts where agent = '".$agentname."'"; $result = MYSQL_QUERY($query); return mysql_result($result, 0); } function GetCurrentLeadsNumByAgent ($agentname){ $query = "SELECT count(*) as total FROM leo_clients where misc = '".$agentname."' and active = 'Y'"; $result = MYSQL_QUERY($query); return mysql_result($result, 0); } function GetTotoalLeadsNumByAgent ($agentname){ $query = "SELECT count(*) as total FROM leo_clients where misc = '".$agentname."' and (active = 'Y' or active = 'H' or active = 'S')"; $result = MYSQL_QUERY($query); return mysql_result($result, 0); } function GetTotoalLeadsNumByAgentAll ($agentname){ $query = "SELECT count(*) as total FROM leo_clients where misc = '".$agentname."'"; $result = MYSQL_QUERY($query); return mysql_result($result, 0); } function GetCommentsNumByAgent ($agentname,$days){ // $query = "SELECT count(*) as total FROM leo_client_pitchcalls where agent = '".$agentname."' and ".'regdatetime <= NOW() AND regdatetime >= DATE_SUB(regdatetime, INTERVAL '.$days.' DAY)'; $query = "SELECT count(*) as total FROM leo_client_logs where log_name = '".$agentname."' and log_date > SUBDATE(NOW(), '".$days." day')"; $result = MYSQL_QUERY($query); return mysql_result($result, 0); } function GetResponseNumByCID ($cid){ $query = "SELECT count(*) as total FROM leo_property_click_log where cid = ".$cid; $result = MYSQL_QUERY($query); return mysql_result($result, 0); } function GetCommentsNumByCID ($cid){ $query = "SELECT count(*) as total FROM leo_client_logs where cid = ".$cid; $result = MYSQL_QUERY($query); return mysql_result($result, 0); } function GetCommentsNumByAgentFlex ($agentname,$days){ $query = "SELECT count(*) as total FROM leo_property_click_log where cid = ".$agentname." and regdatetime > SUBDATE(NOW(), '".$days." day')"; $result = MYSQL_QUERY($query); return mysql_result($result, 0); } function InsertPropertyClickLog ($cid,$mls,$clientip,$clicktime,$ref){ $query = "insert into leo_property_click_log (cid,MLS,clientip,regdatetime,ref) VALUES ($cid,'$mls','$clientip','$clicktime','$ref')"; $result = MYSQL_QUERY($query); } function GetFollowUpCallsNumByCID ($cid){ $query = "SELECT count(*) as total FROM leo_client_followupcalls where cid = ".$cid; $result = MYSQL_QUERY($query); return mysql_result($result, 0); } function GetApptsNumByCID ($cid){ $query = "SELECT count(*) as total FROM leo_client_appts where cid = ".$cid; $result = MYSQL_QUERY($query); $appt1 = mysql_result($result, 0); $query = "SELECT count(*) as total FROM leo_team_efforts where type = 'showing' and cid = ".$cid; $result = MYSQL_QUERY($query); $appt2 = mysql_result($result, 0); $appt3 = $appt1 + $appt2; //return mysql_result($result, 0); return $appt3; } function GetFavoritesNumByCID ($cid){ $query = "SELECT count(*) as total FROM leo_clients_favs where cid = ".$cid; $result = MYSQL_QUERY($query); return mysql_result($result, 0); } function GetShowingNumByUsername ($username){ $query = "SELECT count(*) as total FROM leo_team_efforts where username = '".$username."' and showingclientid > 0"; $result = MYSQL_QUERY($query); return mysql_result($result, 0); } function GetActivenessByUsername ($username){ $query = "SELECT count(*) as total FROM leo_team_efforts where username = '".$username."' and login_ip is not NULL and login_ip <> ''"; $result = MYSQL_QUERY($query); return mysql_result($result, 0); } /* function GetNewlyUpdatedNumber (){ $today = date("Y-m-d"); $query = "SELECT count(*) as MYCOUNT FROM 51jj_properties where ContactDate = SUBDATE(CURDATE(), INTERVAL 1 DAY)"; $result = MYSQL_QUERY($query); if (!$result) { // echo 'Could not run query: ' . mysql_error(); // exit; return "0"; }else{ while($row = mysql_fetch_array($result)){ return $row['MYCOUNT']; } } } */ function format_dimensions($dimension) { $dimString = ' '; $tmp = array();$items = array(); $tmp = preg_split('/Description<\/u>/i', $dimension); $items = preg_split('/
\s*?
/', $tmp[1]); foreach ($items as $item) { $dimString .= '
'; $tt = array(); $t1='';$t2='';$t3='';$t4='';$t5='';$t6='';$t7='';$t8='';$t9='';$t10='';$t11='';$t12='';$t13='';$t14=''; $tt = preg_split('/<\/div>/', $item); $t1 = StripingString($tt[0]); $t2 = StripingString($tt[1]); $t3 = StripingString($tt[2]); $t4 = StripingString($tt[3]); $t5 = StripingString($tt[4]); $t6 = StripingString($tt[5]); $t7 = StripingString($tt[6]); $t8 = StripingString($tt[7]); $t9 = StripingString($tt[8]); $t10 = StripingString($tt[9]); $t11 = StripingString($tt[10]); $t12 = StripingString($tt[11]); $t13 = StripingString($tt[12]); $t14 = StripingString($tt[13]); $dimString .= ''; $dimString .= ''; $dimString .= ''; $dimString .= ''; $dimString .= ''; $dimString .= ''; $dimString .= ''; $dimString .= ''; #print $_; $dimString .= ''; } $dimString .= '
# Room Level Length (m) Width (m) Description
'.$t1.' '.$t2.' '.$t3.' '.$t4.' '.$t5.' '.$t6.' '.$t8.' '.$t9.' '.$t10.' '.$t11.' '.$t12.' '.$t13.' '.$t14.'
'; return $dimString; } function StripingString($thestring) { $thestring = strip_tags($thestring); $thestring = preg_replace('/^\s+/', '', $thestring); $thestring = preg_replace('/\s+$/', '', $thestring); return $thestring; } function is_mls_active_000 ($mls){ $json = []; $active_mls_fn = "/home/leozhang/public_html/lib/rets/mls_active.json"; $active_mls = file_get_contents($active_mls_fn); $json = json_decode($active_mls, true); if (in_array($mls, $json)) { return true; } else { return false; } } function is_mls_active ($mls){ $query = "SELECT count(*) as total FROM wisedeal_properties where MLS = '".$mls."' and (LastStatus = 'AA' or LastStatus = 'A')"; $result=mysql_query($query); $data=mysql_fetch_assoc($result); if($data['total'] > 0){ return true; }else{ return false; } } class Mobile { public static function is_mobile(){ $user_agent = $_SERVER['HTTP_USER_AGENT']; // get the user agent value - this should be cleaned to ensure no nefarious input gets executed $accept = $_SERVER['HTTP_ACCEPT']; // get the content accept value - this should be cleaned to ensure no nefarious input gets executed return false || (preg_match('/ipad/i',$user_agent)) || (preg_match('/ipod/i',$user_agent)||preg_match('/iphone/i',$user_agent)) || (preg_match('/android/i',$user_agent)) || (preg_match('/opera mini/i',$user_agent)) || (preg_match('/blackberry/i',$user_agent)) || (preg_match('/(pre\/|palm os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine)/i',$user_agent)) || (preg_match('/(iris|3g_t|windows ce|opera mobi|windows ce; smartphone;|windows ce; iemobile)/i',$user_agent)) || (preg_match('/(mini 9.5|vx1000|lge |m800|e860|u940|ux840|compal|wireless| mobi|ahong|lg380|lgku|lgu900|lg210|lg47|lg920|lg840|lg370|sam-r|mg50|s55|g83|t66|vx400|mk99|d615|d763|el370|sl900|mp500|samu3|samu4|vx10|xda_|samu5|samu6|samu7|samu9|a615|b832|m881|s920|n210|s700|c-810|_h797|mob-x|sk16d|848b|mowser|s580|r800|471x|v120|rim8|c500foma:|160x|x160|480x|x640|t503|w839|i250|sprint|w398samr810|m5252|c7100|mt126|x225|s5330|s820|htil-g1|fly v71|s302|-x113|novarra|k610i|-three|8325rc|8352rc|sanyo|vx54|c888|nx250|n120|mtk |c5588|s710|t880|c5005|i;458x|p404i|s210|c5100|teleca|s940|c500|s590|foma|samsu|vx8|vx9|a1000|_mms|myx|a700|gu1100|bc831|e300|ems100|me701|me702m-three|sd588|s800|8325rc|ac831|mw200|brew |d88|htc\/|htc_touch|355x|m50|km100|d736|p-9521|telco|sl74|ktouch|m4u\/|me702|8325rc|kddi|phone|lg |sonyericsson|samsung|240x|x320|vx10|nokia|sony cmd|motorola|up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|pocket|kindle|mobile|psp|treo)/i',$user_agent)) || ((strpos($accept,'text/vnd.wap.wml')>0)||(strpos($accept,'application/vnd.wap.xhtml+xml')>0)) || (isset($_SERVER['HTTP_X_WAP_PROFILE'])||isset($_SERVER['HTTP_PROFILE'])) || (in_array(strtolower(substr($user_agent,0,4)),array('1207'=>'1207','3gso'=>'3gso','4thp'=>'4thp','501i'=>'501i','502i'=>'502i','503i'=>'503i','504i'=>'504i','505i'=>'505i','506i'=>'506i','6310'=>'6310','6590'=>'6590','770s'=>'770s','802s'=>'802s','a wa'=>'a wa','acer'=>'acer','acs-'=>'acs-','airn'=>'airn','alav'=>'alav','asus'=>'asus','attw'=>'attw','au-m'=>'au-m','aur '=>'aur ','aus '=>'aus ','abac'=>'abac','acoo'=>'acoo','aiko'=>'aiko','alco'=>'alco','alca'=>'alca','amoi'=>'amoi','anex'=>'anex','anny'=>'anny','anyw'=>'anyw','aptu'=>'aptu','arch'=>'arch','argo'=>'argo','bell'=>'bell','bird'=>'bird','bw-n'=>'bw-n','bw-u'=>'bw-u','beck'=>'beck','benq'=>'benq','bilb'=>'bilb','blac'=>'blac','c55/'=>'c55/','cdm-'=>'cdm-','chtm'=>'chtm','capi'=>'capi','cond'=>'cond','craw'=>'craw','dall'=>'dall','dbte'=>'dbte','dc-s'=>'dc-s','dica'=>'dica','ds-d'=>'ds-d','ds12'=>'ds12','dait'=>'dait','devi'=>'devi','dmob'=>'dmob','doco'=>'doco','dopo'=>'dopo','el49'=>'el49','erk0'=>'erk0','esl8'=>'esl8','ez40'=>'ez40','ez60'=>'ez60','ez70'=>'ez70','ezos'=>'ezos','ezze'=>'ezze','elai'=>'elai','emul'=>'emul','eric'=>'eric','ezwa'=>'ezwa','fake'=>'fake','fly-'=>'fly-','fly_'=>'fly_','g-mo'=>'g-mo','g1 u'=>'g1 u','g560'=>'g560','gf-5'=>'gf-5','grun'=>'grun','gene'=>'gene','go.w'=>'go.w','good'=>'good','grad'=>'grad','hcit'=>'hcit','hd-m'=>'hd-m','hd-p'=>'hd-p','hd-t'=>'hd-t','hei-'=>'hei-','hp i'=>'hp i','hpip'=>'hpip','hs-c'=>'hs-c','htc '=>'htc ','htc-'=>'htc-','htca'=>'htca','htcg'=>'htcg','htcp'=>'htcp','htcs'=>'htcs','htct'=>'htct','htc_'=>'htc_','haie'=>'haie','hita'=>'hita','huaw'=>'huaw','hutc'=>'hutc','i-20'=>'i-20','i-go'=>'i-go','i-ma'=>'i-ma','i230'=>'i230','iac'=>'iac','iac-'=>'iac-','iac/'=>'iac/','ig01'=>'ig01','im1k'=>'im1k','inno'=>'inno','iris'=>'iris','jata'=>'jata','java'=>'java','kddi'=>'kddi','kgt'=>'kgt','kgt/'=>'kgt/','kpt '=>'kpt ','kwc-'=>'kwc-','klon'=>'klon','lexi'=>'lexi','lg g'=>'lg g','lg-a'=>'lg-a','lg-b'=>'lg-b','lg-c'=>'lg-c','lg-d'=>'lg-d','lg-f'=>'lg-f','lg-g'=>'lg-g','lg-k'=>'lg-k','lg-l'=>'lg-l','lg-m'=>'lg-m','lg-o'=>'lg-o','lg-p'=>'lg-p','lg-s'=>'lg-s','lg-t'=>'lg-t','lg-u'=>'lg-u','lg-w'=>'lg-w','lg/k'=>'lg/k','lg/l'=>'lg/l','lg/u'=>'lg/u','lg50'=>'lg50','lg54'=>'lg54','lge-'=>'lge-','lge/'=>'lge/','lynx'=>'lynx','leno'=>'leno','m1-w'=>'m1-w','m3ga'=>'m3ga','m50/'=>'m50/','maui'=>'maui','mc01'=>'mc01','mc21'=>'mc21','mcca'=>'mcca','medi'=>'medi','meri'=>'meri','mio8'=>'mio8','mioa'=>'mioa','mo01'=>'mo01','mo02'=>'mo02','mode'=>'mode','modo'=>'modo','mot '=>'mot ','mot-'=>'mot-','mt50'=>'mt50','mtp1'=>'mtp1','mtv '=>'mtv ','mate'=>'mate','maxo'=>'maxo','merc'=>'merc','mits'=>'mits','mobi'=>'mobi','motv'=>'motv','mozz'=>'mozz','n100'=>'n100','n101'=>'n101','n102'=>'n102','n202'=>'n202','n203'=>'n203','n300'=>'n300','n302'=>'n302','n500'=>'n500','n502'=>'n502','n505'=>'n505','n700'=>'n700','n701'=>'n701','n710'=>'n710','nec-'=>'nec-','nem-'=>'nem-','newg'=>'newg','neon'=>'neon','netf'=>'netf','noki'=>'noki','nzph'=>'nzph','o2 x'=>'o2 x','o2-x'=>'o2-x','opwv'=>'opwv','owg1'=>'owg1','opti'=>'opti','oran'=>'oran','p800'=>'p800','pand'=>'pand','pg-1'=>'pg-1','pg-2'=>'pg-2','pg-3'=>'pg-3','pg-6'=>'pg-6','pg-8'=>'pg-8','pg-c'=>'pg-c','pg13'=>'pg13','phil'=>'phil','pn-2'=>'pn-2','pt-g'=>'pt-g','palm'=>'palm','pana'=>'pana','pire'=>'pire','pock'=>'pock','pose'=>'pose','psio'=>'psio','qa-a'=>'qa-a','qc-2'=>'qc-2','qc-3'=>'qc-3','qc-5'=>'qc-5','qc-7'=>'qc-7','qc07'=>'qc07','qc12'=>'qc12','qc21'=>'qc21','qc32'=>'qc32','qc60'=>'qc60','qci-'=>'qci-','qwap'=>'qwap','qtek'=>'qtek','r380'=>'r380','r600'=>'r600','raks'=>'raks','rim9'=>'rim9','rove'=>'rove','s55/'=>'s55/','sage'=>'sage','sams'=>'sams','sc01'=>'sc01','sch-'=>'sch-','scp-'=>'scp-','sdk/'=>'sdk/','se47'=>'se47','sec-'=>'sec-','sec0'=>'sec0','sec1'=>'sec1','semc'=>'semc','sgh-'=>'sgh-','shar'=>'shar','sie-'=>'sie-','sk-0'=>'sk-0','sl45'=>'sl45','slid'=>'slid','smb3'=>'smb3','smt5'=>'smt5','sp01'=>'sp01','sph-'=>'sph-','spv '=>'spv ','spv-'=>'spv-','sy01'=>'sy01','samm'=>'samm','sany'=>'sany','sava'=>'sava','scoo'=>'scoo','send'=>'send','siem'=>'siem','smar'=>'smar','smit'=>'smit','soft'=>'soft','sony'=>'sony','t-mo'=>'t-mo','t218'=>'t218','t250'=>'t250','t600'=>'t600','t610'=>'t610','t618'=>'t618','tcl-'=>'tcl-','tdg-'=>'tdg-','telm'=>'telm','tim-'=>'tim-','ts70'=>'ts70','tsm-'=>'tsm-','tsm3'=>'tsm3','tsm5'=>'tsm5','tx-9'=>'tx-9','tagt'=>'tagt','talk'=>'talk','teli'=>'teli','topl'=>'topl','hiba'=>'hiba','up.b'=>'up.b','upg1'=>'upg1','utst'=>'utst','v400'=>'v400','v750'=>'v750','veri'=>'veri','vk-v'=>'vk-v','vk40'=>'vk40','vk50'=>'vk50','vk52'=>'vk52','vk53'=>'vk53','vm40'=>'vm40','vx98'=>'vx98','virg'=>'virg','vite'=>'vite','voda'=>'voda','vulc'=>'vulc','w3c '=>'w3c ','w3c-'=>'w3c-','wapj'=>'wapj','wapp'=>'wapp','wapu'=>'wapu','wapm'=>'wapm','wig '=>'wig ','wapi'=>'wapi','wapr'=>'wapr','wapv'=>'wapv','wapy'=>'wapy','wapa'=>'wapa','waps'=>'waps','wapt'=>'wapt','winc'=>'winc','winw'=>'winw','wonu'=>'wonu','x700'=>'x700','xda2'=>'xda2','xdag'=>'xdag','yas-'=>'yas-','your'=>'your','zte-'=>'zte-','zeto'=>'zeto','acs-'=>'acs-','alav'=>'alav','alca'=>'alca','amoi'=>'amoi','aste'=>'aste','audi'=>'audi','avan'=>'avan','benq'=>'benq','bird'=>'bird','blac'=>'blac','blaz'=>'blaz','brew'=>'brew','brvw'=>'brvw','bumb'=>'bumb','ccwa'=>'ccwa','cell'=>'cell','cldc'=>'cldc','cmd-'=>'cmd-','dang'=>'dang','doco'=>'doco','eml2'=>'eml2','eric'=>'eric','fetc'=>'fetc','hipt'=>'hipt','http'=>'http','ibro'=>'ibro','idea'=>'idea','ikom'=>'ikom','inno'=>'inno','ipaq'=>'ipaq','jbro'=>'jbro','jemu'=>'jemu','java'=>'java','jigs'=>'jigs','kddi'=>'kddi','keji'=>'keji','kyoc'=>'kyoc','kyok'=>'kyok','leno'=>'leno','lg-c'=>'lg-c','lg-d'=>'lg-d','lg-g'=>'lg-g','lge-'=>'lge-','libw'=>'libw','m-cr'=>'m-cr','maui'=>'maui','maxo'=>'maxo','midp'=>'midp','mits'=>'mits','mmef'=>'mmef','mobi'=>'mobi','mot-'=>'mot-','moto'=>'moto','mwbp'=>'mwbp','mywa'=>'mywa','nec-'=>'nec-','newt'=>'newt','nok6'=>'nok6','noki'=>'noki','o2im'=>'o2im','opwv'=>'opwv','palm'=>'palm','pana'=>'pana','pant'=>'pant','pdxg'=>'pdxg','phil'=>'phil','play'=>'play','pluc'=>'pluc','port'=>'port','prox'=>'prox','qtek'=>'qtek','qwap'=>'qwap','rozo'=>'rozo','sage'=>'sage','sama'=>'sama','sams'=>'sams','sany'=>'sany','sch-'=>'sch-','sec-'=>'sec-','send'=>'send','seri'=>'seri','sgh-'=>'sgh-','shar'=>'shar','sie-'=>'sie-','siem'=>'siem','smal'=>'smal','smar'=>'smar','sony'=>'sony','sph-'=>'sph-','symb'=>'symb','t-mo'=>'t-mo','teli'=>'teli','tim-'=>'tim-','tosh'=>'tosh','treo'=>'treo','tsm-'=>'tsm-','upg1'=>'upg1','upsi'=>'upsi','vk-v'=>'vk-v','voda'=>'voda','vx52'=>'vx52','vx53'=>'vx53','vx60'=>'vx60','vx61'=>'vx61','vx70'=>'vx70','vx80'=>'vx80','vx81'=>'vx81','vx83'=>'vx83','vx85'=>'vx85','wap-'=>'wap-','wapa'=>'wapa','wapi'=>'wapi','wapp'=>'wapp','wapr'=>'wapr','webc'=>'webc','whit'=>'whit','winw'=>'winw','wmlb'=>'wmlb','xda-'=>'xda-',))) ; } } function genRandomString() { $length = 10; $characters = '0123456789abcdefghijklmnopqrstuvwxyz'; $string = ''; for ($p = 0; $p < $length; $p++) { $string .= $characters[mt_rand(0, strlen($characters))]; } return $string; } class pointLocation { var $pointOnVertex = true; // Check if the point sits exactly on one of the vertices? function pointLocation() { } function pointInPolygon($point, $polygon, $pointOnVertex = true) { $this->pointOnVertex = $pointOnVertex; // Transform string coordinates into arrays with x and y values $point = $this->pointStringToCoordinates($point); $vertices = array(); foreach ($polygon as $vertex) { $vertices[] = $this->pointStringToCoordinates($vertex); } // Check if the point sits exactly on a vertex if ($this->pointOnVertex == true and $this->pointOnVertex($point, $vertices) == true) { return "vertex"; } // Check if the point is inside the polygon or on the boundary $intersections = 0; $vertices_count = count($vertices); for ($i=1; $i < $vertices_count; $i++) { $vertex1 = $vertices[$i-1]; $vertex2 = $vertices[$i]; if ($vertex1['y'] == $vertex2['y'] and $vertex1['y'] == $point['y'] and $point['x'] > min($vertex1['x'], $vertex2['x']) and $point['x'] < max($vertex1['x'], $vertex2['x'])) { // Check if point is on an horizontal polygon boundary return "boundary"; } if ($point['y'] > min($vertex1['y'], $vertex2['y']) and $point['y'] <= max($vertex1['y'], $vertex2['y']) and $point['x'] <= max($vertex1['x'], $vertex2['x']) and $vertex1['y'] != $vertex2['y']) { $xinters = ($point['y'] - $vertex1['y']) * ($vertex2['x'] - $vertex1['x']) / ($vertex2['y'] - $vertex1['y']) + $vertex1['x']; if ($xinters == $point['x']) { // Check if point is on the polygon boundary (other than horizontal) return "boundary"; } if ($vertex1['x'] == $vertex2['x'] || $point['x'] <= $xinters) { $intersections++; } } } // If the number of edges we passed through is odd, then it's in the polygon. if ($intersections % 2 != 0) { return "inside"; } else { return "outside"; } } function pointOnVertex($point, $vertices) { foreach($vertices as $vertex) { if ($point == $vertex) { return true; } } } function pointStringToCoordinates($pointString) { $coordinates = explode(" ", $pointString); return array("x" => $coordinates[0], "y" => $coordinates[1]); } ### Mortgage Calculator Code #$principal = 684000; //Mortgage Amount #$interest_rate = 2.89; //Interest Rate % #$down = $principal *0.10; //10% down payment #$years = 25; #$months = 0; #$compound = 2; //compound is always set to 2 #$frequency = 12; //Number of months (Monthly (12), Semi-Monthly (24), Bi-Weekly(26) and Weekly(52) function calcPay($MORTGAGE, $AMORTYEARS, $AMORTMONTHS, $INRATE, $COMPOUND, $FREQ, $DOWN){ $MORTGAGE = $MORTGAGE - $DOWN; $compound = $COMPOUND/12; $monTime = ($AMORTYEARS * 12) + (1 * $AMORTMONTHS); $RATE = ($INRATE*1.0)/100; $yrRate = $RATE/$COMPOUND; $rdefine = pow((1.0 + $yrRate),$compound)-1.0; $PAYMENT = ($MORTGAGE*$rdefine * (pow((1.0 + $rdefine),$monTime))) / ((pow((1.0 + $rdefine),$monTime)) - 1.0); if($FREQ==12){ return $PAYMENT;} if($FREQ==26){ return $PAYMENT/2.0;} if($FREQ==52){ return $PAYMENT/4.0;} if($FREQ==24){ $compound2 = $COMPOUND/$FREQ; $monTime2 = ($AMORTYEARS * $FREQ) + ($AMORTMONTHS * 2); $rdefine2 = pow((1.0 + $yrRate),$compound2)-1.0; $PAYMENT2 = ($MORTGAGE*$rdefine2 * (pow((1.0 + $rdefine2),$monTime2)))/ ((pow((1.0 + $rdefine2),$monTime2)) - 1.0); return $PAYMENT2; } } #$payment = calcPay($principal, $years, $months, $interest_rate, $compound, $frequency, $down); } ?>