-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication.php
More file actions
130 lines (76 loc) · 2.92 KB
/
application.php
File metadata and controls
130 lines (76 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
/*
ini_set('display_errors',1);
error_reporting(E_ALL);
*/
class TrustNet {
function __construct($username, $listname){
/* Check username and list name are valid */
$userwhite = "/\A([a-zA-Z0-9_]){1,15}\z/";
$listwhite = "/\A([a-zA-Z0-9-_]){1,25}\z/";
if (!(preg_match($userwhite,$username,$matches))) {
exit("<p class=\"error\">Invalid user name</p>");
}
if (!(preg_match($listwhite,$listname,$matches))) {
exit("<p class=\"error\">Invalid list name</p>");
}
/* save variables */
$this->username = $username;
$this->listname = $listname;
$this->fname = $username . "." . $listname;
$this->dName = $this->fname . ".dot";
}
// If file doesn't exist, create it and return False;
// otherwise return True.
public function checkExists() {
if (!(file_exists($this->fname))){
return False;
} else {
return True;
}
}
// Creates new net files if they don't already exist,
// rebuilds them if they do (see trustlist.py)
public function buildNet() {
$com = "python2.6 trustlist.py --seed $this->username --list $this->listname -w ";
shell_exec($com);
}
// Displays the trust net
public function displayNet() {
if (file_exists($this->dName)) {
echo "<div id='cloud'>";
echo "<h3>TrustNet for list <b>$this->listname</b></h3>";
echo "<br />";
echo "<div><img width=\"100%\" src='graph.php?user=$this->username&list=$this->listname'/></div>";
echo "<br><br>";
echo "<p style=\"display:inline\">See <a href='graph.php?user=$this->username&list=$this->listname'>larger</a> | </p>";
echo "<a href='?user=$this->username&list=$this->listname&recalc=1'>Rebuild</a> | ";
echo "<a href='index.php'>Clear</a>";
echo "</div>";
} else {
echo 'asdfasdf';
}
}
public function displayCloud() {
if (file_exists($this->dName)) {
$lines = file($this->fname);
$depth = "-1";
foreach ($lines as $line) {
if ($line[0] == ":") {
$depth = $depth+1;
} else {
if ($depth < 0) { continue; }
$names = split(" ",$line);
foreach ($names as $name) {
echo "<span class='d$depth'><a href='http://twitter.com/#!/$name'>$name</a> </span>";
}
}
}
}
}
}
/*
$TN = new TrustNet('webisteme', 'tne-github');
$TN->displayCloud();
*/
?>