예제 #1
0
<?php

require_once "config.php";
require_once "libs/db_mysql.php";
$SQL = new sqlQueries(PUBLIC_DATABASE_HOST, PUBLIC_DATABASE_DATABASE, PUBLIC_DATABASE_USER, PUBLIC_DATABASE_PASS);
for ($i = 1; $i < 200; $i++) {
    //print($i."\n");
    //this url is public :)
    $info = file_get_contents("https://api.cilabs.net/v1/conferences/ws15/info/attendees?page=" . $i);
    $list = json_decode($info, true);
    foreach ($list['attendees'] as $info) {
        //create company
        $query = "INSERT IGNORE INTO `" . PUBLIC_DATABASE_DATABASE . "`.`companies` ( `name`, `country`) VALUES ('" . addslashes($info['company']) . "', '" . addslashes($info['country']) . "')";
        //print($query."\n");
        $R = $SQL->query($query);
        //find company
        $query = "select `id_companies` from `" . PUBLIC_DATABASE_DATABASE . "`.`companies` where `name` = '" . addslashes($info['company']) . "' and  `country` ='" . addslashes($info['country']) . "' ";
        //print($query."\n");
        $R = $SQL->query2cell($query);
        //print($R."\n");
        //insert attendee
        $query = "INSERT IGNORE INTO `" . PUBLIC_DATABASE_DATABASE . "`.`persons` ( `name`, `position`, `description`, `id_ext`, `id_company`, `country`, `avatar`) \n\t\t\tVALUES ('" . addslashes($info['name']) . "', '" . addslashes($info['career']) . "', '" . addslashes($info['bio']) . "', " . $info['id'] . ", " . $R . ", '" . addslashes($info['country']) . "', '" . addslashes($info['avatar_url']) . "')";
        //print($query."\n");
        $R = $SQL->query($query);
    }
}
?>

예제 #2
0
    $url = str_replace("http://", "", $r['website_url']);
    $url = str_replace("https://", "", $url);
    $url = str_replace("http:/", "", $url);
    $url = str_replace("https:/", "", $url);
    $url = str_replace("www.", "", $url);
    if (strpos($url, "/") > 1) {
        $url = substr($url, 0, strpos($url, "/"));
    }
    //$url = substr($url, 0, strpos($url, "#"));
    //$url = substr($url, 0, strpos($url, "?"));
    print $url . "\n";
    $result = dns_get_record($url);
    print_r($result);
    print "\n\n";
    //extract MX and SPF records
    foreach ($result as $line) {
        if ($line['type'] == "MX") {
            print_r($line);
            $dns_mx .= $line['host'] . " - " . $line['target'] . "\n";
        }
        if ($line['type'] == "TXT" and preg_match("/spf1/", $line['txt'])) {
            print_r($line);
            $dns_spf .= $line['host'] . " - " . $line['txt'] . "\n";
        }
    }
    print $dns_mx . $dns_spf;
    $SQL->query("update " . PUBLIC_DATABASE_DATABASE . ".`startups` set \n\t\t\t\t`dns` = '" . json_encode($result) . "',\n\t\t\t\t`dns_mx` = '" . $SQL->e($dns_mx) . "',\n\t\t\t\t`dns_spf` = '" . $SQL->e($dns_spf) . "'\n\t\t\t\t where id=" . $r['id']);
}
?>

    } else {
        //we don't have a URL but can stuill search with the company_name
        $angel_search = str_replace(" ", "%20", $r['company_name']);
        print "SEARCH FOR COMPANY : {$angel_search} \n";
    }
    $couc = file_get_contents('https://api.angel.co/1/search?type=Startup&query=' . $angel_search . '&access_token=' . $Angellist_tokenauth);
    $info_search = json_decode($couc, true);
    print "SEARCH RESULT : \n";
    print_r($info_search);
    $info = "";
    $info_role = "";
    if ($info_search) {
        //Get Company info
        $info = file_get_contents('https://api.angel.co/1/startups/' . $info_search[0]['id'] . '?access_token=' . $Angellist_tokenauth);
        $info_startup = json_decode($info, true);
        print_r($info_startup);
        //Get Company roles
        $info_role = file_get_contents('https://api.angel.co/1/startups/' . $info_search[0]['id'] . '/roles?access_token=' . $Angellist_tokenauth);
        $info_startup_role = json_decode($info_role, true);
        print_r($info_startup_role);
        if ($info_startup) {
            $SQL->query("update " . PUBLIC_DATABASE_DATABASE . ".`startups` set \n\t\t\t\t`angel_startup` = '" . $SQL->e(json_encode($info_startup)) . "',\n\t\t\t\t`angel_startup_role` = '" . $SQL->e(json_encode($info_startup_role)) . "'\n\t\t\t\t where id=" . $r['id']);
            print "DONE\n";
        } else {
            print "PASS\n";
        }
    }
}
?>

    $code = $tmhOAuth->request('GET', 'https://api.twitter.com/1.1/users/lookup.json', array('screen_name' => $username));
    if ($code == 200) {
        return json_decode($tmhOAuth->response['response'], true);
    } else {
        return false;
    }
}
foreach ($SQL->query2assoc("SELECT `id`,`twitter_url` FROM " . PUBLIC_DATABASE_DATABASE . ".`startups` where `twitter_url`!='' and twitter_followers_count=0 and twitter_url_2 is Null") as $r) {
    //print_r($r);
    $twitter = str_replace("https://twitter.com/", "", $r['twitter_url']);
    $twitter = str_replace("http://twitter.com/", "", $twitter);
    $twitter = str_replace("www.twitter.com/", "", $twitter);
    $twitter = str_replace("twitter.com/", "", $twitter);
    $twitter = str_replace("http://", "", $twitter);
    $twitter = str_replace("https://", "", $twitter);
    $twitter = str_replace("http:/", "", $twitter);
    $twitter = str_replace("https:/", "", $twitter);
    $twitter = str_replace("@", "", $twitter);
    print $twitter . "\n";
    $res = checkTwitter($twitter);
    if ($res and $res[0]) {
        print "update " . PUBLIC_DATABASE_DATABASE . ".`startups` set `twitter_url_2` = '" . $SQL->e($res[0]['url']) . "',\n\t\t\t`twitter_url` = '" . $SQL->e($twitter) . "',\n\t\t\t`twitter_followers_count` = '" . $res[0]['followers_count'] . "',\n\t\t\t`twitter_friends_count` = '" . $res[0]['friends_count'] . "',\n\t\t\t`twitter_description` = '" . $SQL->e($res[0]['description']) . "'\n\t\t\t where id=" . $r['id'];
        $SQL->query("update " . PUBLIC_DATABASE_DATABASE . ".`startups` set `twitter_url_2` = '" . $SQL->e($res[0]['url']) . "',\n\t\t\t`twitter_url` = '" . $SQL->e($twitter) . "',\n\t\t\t`twitter_followers_count` = '" . $res[0]['followers_count'] . "',\n\t\t\t`twitter_friends_count` = '" . $res[0]['friends_count'] . "',\n\t\t\t`twitter_description` = '" . $SQL->e($res[0]['description']) . "'\n\t\t\t where id=" . $r['id']);
        print "DONE\n";
    } else {
        print "PASS\n";
    }
}
?>