$created_time = date("c", 0); } else { $botid = $temp['botid']; $created_time = $temp['created_time']; } $conversations = $fb->get('/' . $conversation_id . '/messages?fields=message,from,created_time', $page_token)->getDecodedBody(); $query = new query(); $query->dbname = $config['database_name']; $query->table = 'conversations_botid'; $query->where = array('conversation_id', $conversation_id); DELETE($query); $query = new query(); $query->dbname = $config['database_name']; $query->table = 'conversations_botid'; $query->value = array(array('conversation_id', $conversation_id), array('botid', $botid), array('created_time', $conversations['data'][0]['created_time'])); INSERT($query); while (count($conversations['data']) > 0) { foreach ($conversations['data'] as $message) { if ($message['from']['id'] != $page_id && $message['created_time'] > $created_time) { $input = $message['message']; $server_message = ""; $response = ""; $error = false; if ($input == "") { $error = true; $server_message .= "[Server Message][Error] Only supports text.\n"; } if (preg_match("/\n/", $input)) { $server_message .= "[Server Message][Notice] Wrap will be ignored.\n"; } $input = str_replace("\n", "", $input);
*/ $log .= "<b>Country target</b>: {$adCountry}<br/>"; if ($adCountry == $countryName || $adCountry == "any") { $log .= "Country: OK<br/>"; /* UPDATE [publink] number of views */ if ($row = SELECT(" * FROM publink_info WHERE pubUID=" . $id . " AND YTID LIKE '" . $link . "'")) { $log .= "YTID + publishID : FOUND<br/>"; UPDATE(" publink_info SET totalView=totalView+1 WHERE pubUID=" . $id . " AND YTID LIKE '" . $link . "'"); /* UPDATE [adlink] number of views*/ UPDATE(" adlink_info SET viewed=viewed+1 WHERE adUID=" . $adUID); /* If the country for this adLink exist just update number of views */ if ($row = SELECT(" * FROM publink_stat WHERE adUID=" . $adUID . " AND countryName LIKE '" . $countryName . "'")) { UPDATE(" publink_stat SET views=views+1 WHERE adUID=" . $adUID . " AND countryName LIKE '" . $countryName . "'"); } else { /* If the country for this adLink does not exist add a row and set it to 1 (number of views */ INSERT(" INTO publink_stat VALUES('" . $adUID . "','" . $countryCode . "','" . $countryName . "',1)"); } $log .= "<b>--- UPDATE DONE ---</b><br/>"; } else { $log .= "YTID({$link}) + publishID({$id}) : NOT Found on DB<br/>"; } } else { $log .= "Country: Missmatch<br/>"; } } } else { //Has been viewd during last GapView $timeago = $Now - $_SESSION['video'][$link]; $log .= "Has been viewed LESS than {$GapTime} seconds ago; {$timeago} seconds ago<br/>"; } } else {