Exemplo n.º 1
0
<?php

session_start();
if (isset($_GET['function'])) {
    $i = new indexer();
    require_once "mysql.class.php";
    $mysql = new mySQL();
    if ($_GET['function'] == 'init') {
        $i->init();
    }
    if ($_GET['function'] == 'indexIt') {
        $result = mysql_query("select count(*) as c from `test`.`crawler_tree`");
        $row = mysql_fetch_array($result);
        $no_of_links = $row['c'];
        //echo $no_of_links;
        $result = mysql_query("select id,url from `test`.`crawler` where ftch=1");
        if ($row = mysql_fetch_array($result)) {
            $id = $row['id'];
            $url = $row['url'];
            $xml = simplexml_load_file("indexData/" . $id . ".xml");
            $title = preg_replace('/^( )*$/', "No title", $xml->title);
            $linksCount = (int) $xml->out->attributes() + (int) $xml->links->attributes();
            $output = mysql_fetch_array(mysql_query("select count(*) as count from test.crawler_tree where child_id={$id}"));
            $inLinks = $output['count'];
            $outXML = simplexml_load_file("../data/links/" . $_SESSION['domainID'] . ".xml");
            if (!($link = $outXML->XPath("/domain/link[url = '{$url}']"))) {
                $link = $outXML->addChild('link');
                $_SESSION['linkID'] = count($outXML);
                $link->addAttribute('id', count($outXML));
                $link->url = $url;
                $link->title = $title;