Exemplo n.º 1
0
/**
 *		CONTINIOUS TRACKING
 *		Tracking:
 *		- User status changes to track if a user is online/offline
 *		- User lastseen (privacy options)
 *		- User profile pictures (and changes)
 *     - User status message (and changes)
 */
function track()
{
    global $DBH, $wa, $tracking_ticks, $tracking_numbers, $whatsspyNotificatons, $crawl_time, $whatsappAuth, $pollCount, $lastseenCount, $statusMsgCount, $picCount, $request_error_queue, $continue_tracker_session;
    $crawl_time = time();
    setupWhatsappHandler();
    retrieveTrackingUsers();
    tracker_log('[init] Started tracking with phonenumber ' . $whatsappAuth['number']);
    if ($continue_tracker_session == false) {
        startTrackerHistory();
        sendNotification($DBH, null, $whatsspyNotificatons, 'tracker', ['title' => 'WhatsSpy Public has started tracking!', 'description' => 'tracker has started tracking ' . count($tracking_numbers) . ' users.', 'event-type' => 'start']);
    } else {
        $continue_tracker_session = false;
    }
    while (true) {
        $crawl_time = time();
        // Socket read
        $tick_start = microtime(true);
        $wa->pollMessage();
        $tick_end = microtime(true);
        tracker_log('[poll #' . $pollCount . '] Tracking ' . count($tracking_numbers) . ' users.       ' . "\r", true, false);
        //	1) LAST SEEN PRIVACY
        //
        // Check lastseen
        if ($pollCount % calculateTick($tracking_ticks['lastseen']) == 0) {
            tracker_log('[lastseen #' . $lastseenCount . '] Checking ' . count($tracking_numbers) . ' users.               ');
            foreach ($tracking_numbers as $number) {
                $wa->sendGetRequestLastSeen($number);
            }
            $lastseenCount++;
        }
        //	2) STATUS MESSAGE (and privacy)
        //
        // Check status message
        if ($pollCount % calculateTick($tracking_ticks['statusmsg']) == 0) {
            tracker_log('[status-msg #' . $statusMsgCount . '] Checking ' . count($tracking_numbers) . ' users.');
            if (count($tracking_numbers) > 0) {
                $wa->sendGetStatuses($tracking_numbers);
            }
            $statusMsgCount++;
        }
        //	3) PROFILE PICTURE (and privacy)
        //
        // Check profile picture
        if ($pollCount % calculateTick($tracking_ticks['profile-pic']) == 0) {
            tracker_log('[profile-pic #' . $picCount . '] Checking ' . count($tracking_numbers) . ' users.');
            foreach ($tracking_numbers as $number) {
                $wa->sendGetProfilePicture($number, true);
            }
            $picCount++;
        }
        //	4) DATABASE ACCOUNT REFRESH
        //
        // Check user database and refresh user set every hour but with a offset of 80 seconds.
        if ($pollCount % calculateTick($tracking_ticks['refresh-db']) == calculateTick($tracking_ticks['refresh-db'] - 80)) {
            retrieveTrackingUsers(true);
        }
        //  5) SOCKET RESET AND LOGIN
        //
        // Disconnect and reconnect with whatsapp to prevent dead tracker
        if ($pollCount % calculateTick($tracking_ticks['reset-socket']) == calculateTick($tracking_ticks['reset-socket'] - 40)) {
            resetSocket();
            retrieveTrackingUsers(false);
        }
        //	6) DATABASE ACCOUNT VERIFY CHECK
        //
        // Verify any freshly inserted accounts and check if there really whatsapp users.
        // Check everey 5 minutes.
        // When the user is verified the number is automaticly added to the tracker running DB.
        if ($pollCount % calculateTick($tracking_ticks['verify-check']) == 0) {
            verifyTrackingUsers();
        }
        //	7) WHATSAPP PING
        //
        // Keep connection alive (<300s)
        if ($pollCount % calculateTick($tracking_ticks['keep-alive']) == 0) {
            tracker_log('[keep-alive] Ping sent.' . "\r", true, false);
            $wa->sendPing();
        }
        // usage of 39512f5ea29c597f25483697471ac0b00cbb8088359c219e98fa8bdaf7e079fa
        $pollCount++;
        // Draw the socket read a draw
        if ($tick_end - $tick_start < 1.0) {
            sleep(1);
        }
    }
}
Exemplo n.º 2
0
function track()
{
    global $DBH, $wa, $tracking_numbers, $whatsspyNMAKey, $crawl_time, $whatsappAuth;
    $pollCount = 0;
    $lastseenCount = 0;
    $statusMsgCount = 0;
    $picCount = 0;
    $crawl_time = time();
    setupWhatsappHandler();
    retrieveTrackingUsers();
    echo '[init] Started tracking with phonenumber ' . $whatsappAuth['number'] . "\n";
    startTrackerHistory();
    sendNMAMessage($whatsspyNMAKey, 'WhatsSpy', 'Tracker started.', 'Whatsspy tracker has started tracking ' . count($tracking_numbers) . ' users.', '1');
    while (true) {
        $crawl_time = time();
        // Socket read
        $tick_start = microtime(true);
        $wa->pollMessage();
        $tick_end = microtime(true);
        echo '[poll #' . $pollCount . '] Tracking ' . count($tracking_numbers) . ' users.' . "\n";
        //	1) LAST SEEN PRIVACY
        //
        // Check lastseen (every 2 hours)
        if ($pollCount % calculateTick(60 * 60 * 2) == 0) {
            echo '[lastseen #' . $lastseenCount . '] Checking ' . count($tracking_numbers) . ' users.' . "\n";
            foreach ($tracking_numbers as $number) {
                $wa->sendGetRequestLastSeen($number);
            }
            $lastseenCount++;
        }
        //	2) STATUS MESSAGE (and privacy)
        //
        // Check status message (every 2 hours)
        if ($pollCount % calculateTick(60 * 60 * 2) == 0) {
            echo '[status-msg #' . $statusMsgCount . '] Checking ' . count($tracking_numbers) . ' users.' . "\n";
            if (count($tracking_numbers) > 0) {
                $wa->sendGetStatuses($tracking_numbers);
            }
            $statusMsgCount++;
        }
        //	3) PROFILE PICTURE (and privacy)
        //
        // Check profile picture (every 6 hours)
        if ($pollCount % calculateTick(60 * 60 * 6) == 0) {
            echo '[profile-pic #' . $picCount . '] Checking ' . count($tracking_numbers) . ' users.' . "\n";
            foreach ($tracking_numbers as $number) {
                $wa->sendGetProfilePicture($number, true);
            }
            $picCount++;
        }
        //	4) DATABASE ACCOUNT REFRESH
        //
        // Check user database and refresh user set every hour.
        // Check this at the end
        if ($pollCount % calculateTick(60 * 60 * 1) == calculateTick(60 * 60 * 1 - 1)) {
            retrieveTrackingUsers(true);
        }
        //	5) DATABASE ACCOUNT VERIFY CHECK
        //
        // Verify any freshly inserted accounts and check if there really whatsapp users.
        // Check everey 5 minutes.
        // When the user is verified the number is automaticly added to the tracker running DB.
        if ($pollCount % calculateTick(60 * 5) == 0) {
            verifyTrackingUsers();
        }
        //	6) WHATSAPP PING
        //
        // Keep connection alive (<300s)
        if ($pollCount % calculateTick(60 * 2) == 0) {
            echo '[keep-alive] Ping sent' . "\n";
            $wa->sendPing();
        }
        // usage of 39512f5ea29c597f25483697471ac0b00cbb8088359c219e98fa8bdaf7e079fa
        $pollCount++;
        // Draw the socket read a draw
        if ($tick_end - $tick_start < 2.0) {
            sleep(2);
        }
    }
}
Exemplo n.º 3
0
/**
 *		CONTINIOUS TRACKING
 *		Tracking:
 *		- User status changes to track if a user is online/offline
 *			- User lastseen (privacy options) (attached to online/offline status)
 *		- User profile pictures (and changes)
 *     - User status message (and changes)
 */
function track()
{
    global $DBH, $wa, $tracking_ticks, $tracking_numbers, $whatsspyNotificatons, $crawl_time, $whatsappAuth, $pollCount, $lastseenCount, $statusMsgCount, $picCount, $request_error_queue, $continue_tracker_session, $whatsspyPerformanceMode;
    $crawl_time = time();
    setupWhatsappHandler();
    retrieveTrackingUsers();
    tracker_log('[init] Started tracking with phonenumber ' . $whatsappAuth['number']);
    if ($continue_tracker_session == false) {
        startTrackerHistory();
        sendNotification($DBH, null, $whatsspyNotificatons, 'tracker', ['title' => 'WhatsSpy Public has started tracking!', 'description' => 'tracker has started tracking ' . count($tracking_numbers) . ' users.', 'event-type' => 'start']);
    } else {
        $continue_tracker_session = false;
    }
    while (true) {
        $crawl_time = time();
        // Socket read
        $tick_start = microtime(true);
        if ($whatsspyPerformanceMode === true) {
            while (microtime(true) - $tick_start < 1.0 && $wa->pollMessage() === true) {
                echo microtime(true) - $tick_start . "\r\n";
                tracker_debug('Socket read called with poll time: ' . microtime(true) - $tick_start);
            }
        } else {
            $wa->pollMessage();
        }
        $tick_end = microtime(true);
        $poll_took = number_format($tick_end - $tick_start, 4);
        // Check if database set is up to date
        if (count($tracking_numbers) > base64_decode('NzAw')) {
            tracker_log(base64_decode("UEiQOiBGYXRhbCBFcnJvcjogVHJhY2tpbmcgdG9vIG1hbnkgY29udGFjdHMsIGFib3J0aW5nIHRyYWNraW5nLg=="), true, true);
            exit;
        }
        list($usec, $sec) = explode(' ', microtime());
        // split the microtime on space with two tokens $usec and $sec.
        $usec = str_replace("0.", ".", number_format($usec, 4));
        // remove the leading '0.' from usec
        tracker_log("[poll #{$pollCount}] Tracking " . count($tracking_numbers) . " users (poll took {$poll_took})", true, false);
        //	1) STATUS MESSAGE (and privacy)
        //
        // Check status message
        if ($pollCount % calculateTick($tracking_ticks['statusmsg']) == 0) {
            tracker_log('[status-msg #' . $statusMsgCount . '] Checking ' . count($tracking_numbers) . ' users.');
            if (count($tracking_numbers) > 0) {
                $wa->sendGetStatuses($tracking_numbers);
            }
            $statusMsgCount++;
        }
        //	2) PROFILE PICTURE (and privacy)
        //
        // Check profile picture
        if ($pollCount % calculateTick($tracking_ticks['profile-pic']) == 0) {
            tracker_log('[profile-pic #' . $picCount . '] Checking ' . count($tracking_numbers) . ' users.');
            foreach ($tracking_numbers as $number) {
                $wa->sendGetProfilePicture($number, true);
            }
            $picCount++;
        }
        //	3) DATABASE ACCOUNT REFRESH
        //
        // Check user database and refresh user set every hour but with a offset of 80 seconds.
        if ($pollCount % calculateTick($tracking_ticks['refresh-db']) == calculateTick($tracking_ticks['refresh-db'] - 80)) {
            retrieveTrackingUsers(true);
        }
        //  4) SOCKET RESET AND LOGIN
        //
        // Disconnect and reconnect with whatsapp to prevent dead tracker
        if ($pollCount % calculateTick($tracking_ticks['reset-socket']) == calculateTick($tracking_ticks['reset-socket'] - 40)) {
            resetSocket();
            retrieveTrackingUsers(false);
        }
        //	5) DATABASE ACCOUNT VERIFY CHECK
        //
        // Verify any freshly inserted accounts and check if there really whatsapp users.
        // Check everey 5 minutes.
        // When the user is verified the number is automaticly added to the tracker running DB.
        if ($pollCount % calculateTick($tracking_ticks['verify-check']) == 0) {
            verifyTrackingUsers();
        }
        //	6) WHATSAPP PING
        //
        // Keep connection alive (<300s)
        if ($pollCount % calculateTick($tracking_ticks['keep-alive']) == 0) {
            tracker_log('[keep-alive] Ping sent.', true, false);
            $wa->sendPing();
        }
        // usage of 39512f5ea29c597f25483697471ac0b00cbb8088359c219e98fa8bdaf7e079fa
        $pollCount++;
        // Sleep if no more messages could be processed.
        if ($poll_took < 1.0) {
            $sleeping = 1.0 - $poll_took;
            usleep($sleeping * 1000000);
        }
    }
}