root/trunk/robots/path_finder.bot.php

Revision 1, 1.8 KB (checked in by anonymous, 7 years ago)

initial import

Line 
1#!/usr/bin/php
2<?
3include ('../includes/includes.inc.php');
4
5function apostrofize(&$array)
6{
7    foreach($array as $item)
8            $array = "'".$item."'";
9
10}
11
12$db =& DB::connect($dsn);
13if (DB::isError($db))
14                error_log($_SERVER['HTTP_HOST'].' | '.__FILE__.' | Connexion SQL impossible : '.$db->getMessage());
15
16$db->setFetchMode(DB_FETCHMODE_ASSOC);
17
18$path = array();
19
20$all_id = $db->getCol('SELECT id FROM user WHERE status=?',0, 'ok');
21
22foreach($all_id as $id)
23{
24    unset($delete_array);
25    unset($friend_l3);
26    $delete_list = "'".$id."'";
27    print 'level 0: '.$id."\n";
28    $all_id_friends = explode(',', $db->getOne('SELECT friends_id FROM cache_user WHERE id=?',$id));
29
30    foreach($all_id_friends as $id_friend)
31        $delete_array[] = "'".$id_friend."'";
32    $delete_array[] = "'".$id."'";
33    $delete_array = array_unique($delete_array);
34    $delete_list = implode(',', $delete_array);
35
36    foreach($all_id_friends as $id_friend)
37    {
38        print "\tlevel 1: ".$id_friend."\n";
39        $all_id_foaf = $db->getCol('SELECT id_friend FROM relation WHERE id=? AND id_friend NOT IN ('.$delete_list.')',0, $id_friend);
40        $path[$id][] = $id_friend;
41    }
42
43   
44
45        foreach($all_id_foaf as $id_foaf)
46                $delete_array[] = "'".$id_foaf."'";
47        $delete_array[] = "'".$id."'";
48        $delete_array = array_unique($delete_array);
49        $delete_list = implode(',', $delete_array);
50
51    foreach($all_id_foaf as $id_foaf)
52        {
53                print "\t\tlevel 2: ".$id_foaf."\n";
54                $all_id_l3 = $db->getCol('SELECT id_friend FROM relation WHERE id=? AND id_friend NOT IN ('.$delete_list.')',0, $id_foaf);
55                $friend_l3 = array_merge($friend_l3, $all_id_l3);
56       
57        }
58    if(is_array($friend_l3))
59    foreach($friend_l3 as $id3)
60        print "\t\t\tl3: $id3\n";
61
62    print "\n";
63
64
65}
66
67$db->disconnect();
68?>
Note: See TracBrowser for help on using the browser.