<?php

/**
 * AIFS OSINT Get new remote version
 * @digitaloversight
 */
include_once '../common/tool/DomainSelector.php';
require_once '../config/tool/DomainSelector.php';
include_once '../common/sql/Sql.php';
include_once '../common/sql/SqlStatement.php';
include_once '../common/tool/FetchFopen.php';
$conf = new Config('osint');
$helper = new Common('osint', $conf->global_path);
$fetch = new FetchFopen();
$dbh = new SQL_Class("aifs");
$sql = $dbh->execute("SELECT id, url FROM osint_url WHERE dead_link = 0 ORDER BY rand() LIMIT 1");
list($uid, $url) = $sql->fetch_array();
// fetch lastest version
$sql = $dbh->execute("SELECT size, date\r\n                        FROM osint_version\r\n                        WHERE fk_osint_url_id=" . $uid . " ORDER BY date desc LIMIT 1");
list($size, $date) = $sql->fetch_array();
if (strpos($date, date("Y") . '-' . date("m") . '-' . date("d")) !== false) {
    die;
}
// fetch online copy
$content = $fetch->getContent($url);
// compare and save
if ($size != strlen(addslashes($content))) {
    $dbh->execute("INSERT INTO osint_version SET  fk_osint_url_id = '" . $uid . "',\r\n                                                                        content ='" . addslashes($content) . "',\r\n                                                                        size ='" . strlen(addslashes($content)) . "',\r\n                                                                        date = NOW()");
    $sql = $dbh->execute("SELECT tag FROM osint_tags WHERE fk_osint_url_id='" . $uid . "' LIMIT 1");
    list($tag) = $sql->fetch_array();
    if (strlen($tag) > 1) {
<?php

/**
 * AIFS Routine DNINT url pipeline
 * Copyright (c) digitaloversight
 * @version 2016-01-07 1.02 RC2
 */
include_once '../config/tool/DomainSelector.php';
include_once '../common/tool/DomainSelector.php';
include_once '../common/sql/Sql.php';
include_once '../common/sql/SqlStatement.php';
include_once '../common/tool/FetchFopen.php';
$conf = new Config('dnint');
$helper = new Common('osint', $conf->global_path);
$dbh = new SQL_Class('aifs');
$fetch = new FetchFopen('dnint');
error_reporting($conf->debug);
ini_set('error_reporting', $conf->debug);
$sql = $dbh->execute("SELECT url FROM url_tld_com \n                        WHERE osint_submit=0 AND subchance = 0 ORDER by id DESC LIMIT 1");
list($myurl) = $sql->fetch_array();
$sql = $dbh->execute('SELECT * FROM dnint_url ORDER BY id DESC LIMIT 1');
list($id, $url, $time) = $sql->fetch_array();
if ($myurl != $url) {
    $sql = $dbh->execute("INSERT INTO dnint_url SET url='" . $myurl . "'");
}
$sql = $dbh->execute('SELECT * FROM dnint_url ORDER BY id DESC LIMIT 1');
list($id, $url, $time) = $sql->fetch_array();
$sql = $dbh->execute("SELECT COUNT(*) FROM dnint_url_contents WHERE fk_dnint_url_id=" . $id);
if ($sql->sql_result() != 0) {
    die;
}