<?php

// This is the main file for sending bulk emails to members for various reasons. Call this file from the address bar.
//
// Normally runs in test mode, set the variable sendit=true to send the emails.
//
// i.e. send_emails.php?sendit=true
//

	include "library.php";

        // don't call start_code(), seessions not available in cron processes
//	$cxn = start_code( true );


	ini_set( "error_log", $_SESSION['pathroot']."/error_log.txt" );

	ini_set( "display_errors", "on" );
	ini_set( "display_startup_errors", "on" );

    error_reporting( E_ALL & ~E_DEPRECATED & ~E_WARNING );

							// set limits to allow uploading large photos
							
	ini_set( "upload_max_filesize", "16M" );
	ini_set( "post_max_size", "16M" );		
	ini_set( "max_input_time", 300 );		
	ini_set( "max_execution_time'", 300 );		

			
	ini_set( "date.timezone", "Australia/Melbourne" );		

	$database = "academi1_chatcity";
		
	$cxn = db_login( $database );


	$cxn_common = db_common_login();


    $_SESSION['sitename'] = "Chat City";

    $total_emails = 0;
    
    $report_emails_sent = false;
    
    $error_logging = false;
    
    
//        $_SESSION['http_protocol'] = "http";
        
//    echo  microtime( true )."<br>";


	    //********************************************************************************

    if ($error_logging)
        error_log( "\n.\n", 3, "/home/academi1/m-m-ventures.com/chatcity/error_log" );

    if ($error_logging)
        error_log( "Start age error email\n", 3, "/home/academi1/m-m-ventures.com/chatcity/error_log" );

	include "send_age_error_email.php";

    if ($error_logging)
        error_log( "End age error email\n", 3, "/home/academi1/m-m-ventures.com/chatcity/error_log" );


	    //********************************************************************************

    if ($error_logging)
        error_log( "Start photo email\n", 3, "/home/academi1/m-m-ventures.com/chatcity/error_log" );

	include "send_photo_email.php";

    if ($error_logging)
        error_log( "End photo email\n", 3, "/home/academi1/m-m-ventures.com/chatcity/error_log" );
    

	    //********************************************************************************

    if ($error_logging)
        error_log( "Start verify email\n", 3, "/home/academi1/m-m-ventures.com/chatcity/error_log" );

	include "send_verify_reminder_email.php";

    if ($error_logging)
        error_log( "End verify email\n", 3, "/home/academi1/m-m-ventures.com/chatcity/error_log" );
    

	    //********************************************************************************

    if ($error_logging)
        error_log( "Start social media email\n", 3, "/home/academi1/m-m-ventures.com/chatcity/error_log" );
    
	include "send_social_media_email.php";

    if ($error_logging)
        error_log( "End social media email\n", 3, "/home/academi1/m-m-ventures.com/chatcity/error_log" );



	    //********************************************************************************

    if ($error_logging)
        error_log( "Start twelve month email\n", 3, "/home/academi1/m-m-ventures.com/chatcity/error_log" );

	include "send_twelve_month_deactivation_email.php";

    if ($error_logging)
        error_log( "End twelve month email\n", 3, "/home/academi1/m-m-ventures.com/chatcity/error_log" );


	    //********************************************************************************
	
    if ($error_logging)
        error_log( "Start new member email\n", 3, "/home/academi1/m-m-ventures.com/chatcity/error_log" );
	
	include "send_new_member_update.php";

    if ($error_logging)
        error_log( "End new member email\n", 3, "/home/academi1/m-m-ventures.com/chatcity/error_log" );
	
	
//	if ($total_emails > 0)
//        send_email( "Academic Dating", "noreply@academicdating.net", "mark.mcilroy@outlook.com", "Academic Dating", "noreply@academicdating.net", "Total emails sent, ".$total_emails, "", "", $cxn, "live" );

	
//    echo  microtime( true )."<br>";

    echo "<br><br>Finished all<br>";

?>