<?php

	include "library.php";

	$cxn = start_code();

    exit_if_search_bot();


			/* get variables */

	$verifyid = val( $_GET, "verifyid" );

	$code = val( $_GET, "code" );

        
//	if (val( $_SESSION, "screen_width" ) == "")
//	{
//        write_head_section_of_page( "", $cxn, true );
//
//        echo "<body onload='js_set_screen_parameters();'>";
//
//		exit();
//	}


        // may be called by a search bot
        
    if ($verifyid == "")
//    if ($verifyid == "" || $code == "")
		echo red( "ERROR: Invalid parameters" );
    else
    {
        page_header( "", $cxn, true );
        
        
        	/* check parameters */
        
        crash_if_missing( $verifyid, "verify id missing in verify email address", $cxn );
        

        	/* look for member */
        
        //	$query = "SELECT id FROM profile WHERE id = ".$verifyid." AND email_verification_code = '".$code."'";
        
        $query = "SELECT id, email_address FROM advertiser_profile WHERE id = ".$verifyid;
        
        if (! query_has_rows( $query, $cxn ) )
        	echo red( "ERROR: Invalid parameters" );
        else
        {
        	$result = run_query( $query, $cxn );
        
        	$data = get_row( $result );
        
       
                // verify all profiles with this email address
                
        	$query = "UPDATE advertiser_profile SET email_address_valid = 'yes', returned_mail = 'no' WHERE email_address = '".$data['email_address']."'";
        
        	$result = run_query( $query, $cxn );
        
        
//        	$query2 = "INSERT INTO account_activity (member_id, event, event_datetime) VALUES (".$verifyid.", 'Email address verified by member', '".date("Y-m-d H:i:s")."')";
//        
//        	$result2 = run_query( $query2, $cxn );
        
        
        	echo black( "<br>Email address verified<br><br>Your account has been activated<br><br><br>" );
        }
    }	

	echo show_home_link();
	
	
	
    echo "<br><br><br><br><br>";



    echo "</body>";
	
    echo "</html>";

?>