Exemplo n.º 1
0
function main($lat, $lon, $offset, $date_search, $distance_tolerance)
{
    $rows_per_page = 10;
    $cxn = $GLOBALS['cxn'];
    $sql = "SELECT * FROM user_events\n\t\t\tWHERE end_date >= '{$date_search}'\n\t\t\tORDER BY start_date ASC\n\t\t\tLIMIT {$offset}, {$rows_per_page}";
    $res = mysqli_query($cxn, $sql) or die("could not pull events");
    //echo $sql;
    $count = mysqli_num_rows($res);
    //echo "Count:".$count;
    if ($count == 0) {
        //user has no events!
        $arr = array("status" => 0, "content" => "No events!");
        echo json_encode($arr);
        exit;
    }
    // all results will be appended to this var:
    $search_output = "";
    while ($row = mysqli_fetch_assoc($res)) {
        //event_id	user_id	event_title	event_description	end_date	start_date	date_created	public
        extract($row);
        //echo "pulling event $event_id <br />";
        $query_id = "SELECT * FROM event_address WHERE event_id = '{$event_id}'";
        $res2 = mysqli_query($cxn, $query_id) or die("failed to pull address");
        $row_addy = mysqli_fetch_assoc($res2);
        //address_id	event_id	address_text	x_coord	y_coord
        extract($row_addy);
        $distance = distance($x_coord, $y_coord, $lat, $lon, "m");
        /* after everything is extracted:
        			assemble the event and make the html output
        			*/
        if ($distance <= $distance_tolerance) {
            $all_vars = array("event_id" => $event_id, "user_id" => $user_id, "event_description" => $event_description, "event_title" => $event_title, "start_date" => $start_date, "end_date" => $end_date, "venue_address" => $address_text, "lat" => $x_coord, "lon" => $y_coord, "distance" => $distance, "search_output" => $search_output, "isContactInfo" => $is_contactable, "contactInfo" => $contact_info, "contactType" => $contact_type);
            $search_output = search_output_func_users($all_vars);
            //see search_functions.php
        }
    }
    $content_array = array("status" => 1, "content" => $search_output);
    return $content_array;
}
Exemplo n.º 2
0
        //user has no events!
        $arr = array("status" => 1, "content" => "You have not created any events!");
        echo json_encode($arr);
        exit;
    }
    $search_output = "";
    while ($row = mysqli_fetch_assoc($result)) {
        //event_id	user_id	event_title	event_description	end_date	start_date	date_created	public
        extract($row);
        // $event_id = the event id to find the address with
        $query_id = "SELECT * FROM event_address WHERE event_id = '{$event_id}'";
        $res = mysqli_query($cxn, $query_id) or die("failed to pull address");
        $row_addy = mysqli_fetch_assoc($res);
        //address_id	event_id	address_text	x_coord	y_coord
        extract($row_addy);
        $current_lat = $_REQUEST['current_lat'];
        $current_lon = $_REQUEST['current_lon'];
        $distance = distance($x_coord, $y_coord, $current_lat, $current_lon, "m");
        /* after everything is extracted:
        			assemble the event and make the html output
        			*/
        $all_vars = array("event_id" => $event_id, "user_id" => $user_id, "event_description" => $event_description, "event_title" => $event_title, "start_date" => $start_date, "end_date" => $end_date, "venue_address" => $address_text, "lat" => $x_coord, "lon" => $y_coord, "distance" => $distance, "search_output" => $search_output, "isContactInfo" => $is_contactable, "contactInfo" => $contact_info, "contactType" => $contact_type);
        $search_output = search_output_func_users($all_vars);
        //see search_functions.php
    }
    $arr = array("status" => 2, "content" => $search_output);
    echo json_encode($arr);
} else {
    $arr = array("status" => 1, "content" => "You are not logged in!");
    echo json_encode($arr);
}
Exemplo n.º 3
0
function pull_ALL_events($lat, $lon, $offset)
{
    //could be dirty
    /*
    	$offset = preg_replace("#[^0-9]#", "", $offset);
    	$rows_per_page = 7;
    	if($GLOBALS['include_YQL'] == false)
    $rows_per_page = 10;
    */
    // date searching
    $d = DATE_TO_SEARCH_FROM;
    $d2 = DATE_TO_SEARCH_TO;
    // DO YQL SECTION FIRST
    $cxn = $GLOBALS['cxn'];
    $main_array = array();
    // create an emptry array
    if ($GLOBALS['include_YQL'] == true) {
        $qry = "SELECT * FROM YQL_event_address\n\t\t\t\tWHERE \n\t\t\t\t'{$d}' <= (SELECT end_date FROM YQL_events \n\t\t\t\tWHERE event_id = YQL_event_address.event_id)\n\t\t\t\t";
        //LIMIT $offset, $rows_per_page
        $res = mysqli_query($cxn, $qry) or die("couldn't do the db loc thing...");
        while ($row = mysqli_fetch_assoc($res)) {
            extract($row);
            $d_total = distance($lat, $lon, $x_coord, $y_coord, "m");
            // the sub array
            $event = array("origin" => "YQL", "id" => $event_id, "distance" => $d_total, "address_DB" => 0, "lat" => $x_coord, "lon" => $y_coord);
            //$distances[$event_id] = $d_total;
            array_push($main_array, $event);
        }
        //end compare and extract loc data while.
    }
    // END YQL
    // DO USER SECTION NEXT
    $qry = "SELECT * FROM event_address\n\t\t\tWHERE\n\t\t\t'{$d}' <= (SELECT end_date FROM user_events \n\t\t\tWHERE event_id = event_address.event_id)";
    //LIMIT $offset, $rows_per_page
    $res = mysqli_query($cxn, $qry) or die("couldn't do the db loc thing...");
    while ($row = mysqli_fetch_assoc($res)) {
        extract($row);
        $d_total = distance($lat, $lon, $x_coord, $y_coord, "m");
        // the sub array
        $event = array("origin" => "user", "id" => $event_id, "distance" => $d_total, "address_DB" => $address_text, "lat" => $x_coord, "lon" => $y_coord);
        //$distances[$event_id] = $d_total;
        array_push($main_array, $event);
    }
    //end compare and extract loc data while.
    // NOW SORT THIS multidimen array
    $main_array = sortByOneKey($main_array, "distance");
    // MAIN LOOP
    $search_output = "";
    // you have to do the limit down here haha
    $offset = preg_replace("#[^0-9]#", "", $offset);
    $rows_per_page = 9;
    if ($GLOBALS['include_YQL'] == false) {
        $rows_per_page = 9;
    }
    $i = 0;
    foreach ($main_array as $event_array) {
        // offset =
        if ($i > $offset + $rows_per_page) {
            //echo "break tripped: i=$i and Offset=$offset, rows/page=$rows_per_page";
            break;
        }
        if (!($i < $offset)) {
            //echo "continue tripped: i=$i and offset=$offset";
            /*
            		echo "<pre>";
            		print_r($event_array);
            		echo "</pre>";
            */
            // THIS PULLS EVENT INFO VIA ID
            //print_r($event_array);
            extract($event_array);
            if ($origin == "YQL") {
                $event_row = get_all_event_list_YQL($id);
                if ($event_row != null) {
                    extract($event_row);
                }
                $all_vars = array("event_id" => $event_id, "user_id" => 0, "event_description" => $event_description, "event_title" => $event_title, "start_date" => $start_date, "country_name" => $country_name, "venue_name" => $venue_name, "venue_zip" => $venue_zip, "venue_state" => $venue_state, "lat" => $lat, "lon" => $lon, "distance" => $distance, "search_output" => $search_output);
                $search_output = search_output_func_YQL($all_vars);
                //see search_functions.php
            } else {
                if ($origin == "user") {
                    // do user stuff here
                    $event_row = get_all_event_list_users($id);
                    if ($event_row != null) {
                        extract($event_row);
                    }
                    $all_vars = array("event_id" => $event_id, "user_id" => $user_id, "event_description" => $event_description, "event_title" => $event_title, "start_date" => $start_date, "end_date" => $end_date, "venue_address" => $address_DB, "lat" => $lat, "lon" => $lon, "distance" => $distance, "search_output" => $search_output, "isContactInfo" => $is_contactable, "contactInfo" => $contact_info, "contactType" => $contact_type);
                    $search_output = search_output_func_users($all_vars);
                    //see search_functions.php
                }
            }
        }
        // end inner else
        $i++;
    }
    //end loop for location search	 FOREACH
    return $search_output;
}