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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
| <?php
/*
// this php source code is a 100% original invention of
// myself (email:voltaic@thcnet.net) and therefore i
// hereby release this code and all derivative works as
// free software under the gpl (general public license).
// the text and details of this license can be found at
// http://www.gnu.org/copyleft/gpl.html and i encourage
// everyone to use the gpl license for all software.
//
// blather1: this source code comes with no warranty,
// expressed or implied. this source code is not even
// guaranteed to work! if this source code formats your
// hard drive i am not responsible (although i have to
// admit, i would be surprised). this source code is
// not even guaranteed to take up space on your hard
// drive.
//
// blather2: neither the author nor this source code is in
// any way shape or form affiliated, responsible for,
// responsible to, connected to, or reincarnated from
// distributed.net or the agents of distributed.net so
// don't be bugging them to change/update/fix/deify this
// source code because they aren't responsible for it.
// in the same way, neither distributed.net nor the
// agents of distributed.net are in any way shape or form
// affiliated, responsible for, responsible to, connected
// to, or reincarnated from myself or this source code.
// this source code accesses publically available resources
// on a public web server belonging to distributed.net and
// is not any kind of a devious or malicious software.
*/
class rawhide {
/*
// object-wide variables.
// each one is something useful. no temporary or throw-away.
// ordered by relation: dnet info, dates, and blocks.
*/
var $dnetNumber = "1";
var $dnetName = "unknown";
var $dnetContest = "rc5-64";
var $dnetBaseURL = "http://stats.distributed.net/";
var $dnetStatsURL = "/psummary.php3?id=";
var $dnetRawURL = "/phistory_raw.php3?id=";
var $dnetStatsDown = FALSE;
var $dateFirst = 0;
var $dateLast = 0;
var $dateBest = 0;
var $dateYesterday = 0;
var $dateTotal = 1;
var $dateStyle = "";
var $blocksFirst = "0";
var $blocksLast = "0";
var $blocksBest = "0";
var $blocksYesterday = "0";
var $blocksTotal = "0";
var $blocksAverage = "0";
/*
// constructor function - called when object is created in html code.
// if no number is provided, it will use mine. ;-)
*/
function rawhide( $num=49035, $style="j F Y" ) {
$this->dnetNumber = $num;
$this->dnetStatsURL .= $num;
$this->dnetRawURL .= $num;
$this->dateStyle = $style;
if( ( $contest != "rc5-64" ) AND ( $contest != "ogr-24" ) AND ( $contest != "ogr-25" ) ) {
$contest = "rc5-64";
}
$this->dnetContest = $contest;
/*
// here we attempt to open the raw stats file at distributed.net.
*/
$theStats = file( $this->dnetBaseURL.$this->dnetContest.$this->dnetRawURL );
if( $theStats ) {
/*
// use a state variable $indexTracker to determine where we are in the stats file
// and to treat the line of data accordingly. if $indexTracker == "" at the end
// of the while loop or if $theStats not defined, statsbox is "down".
*/
$indexTracker = "";
while( list( $lineNumber, $lineInfo ) = each( $theStats ) ) {
if( $indexTracker == "" AND !ereg( "^---BEGIN HEADER---", $lineInfo ) ) {
continue;
} elseif( ereg( "^---BEGIN HEADER---", $lineInfo ) ) {
$indexTracker = "header";
continue;
} elseif( ereg( "^---BEGIN DATA---", $lineInfo ) ) {
$indexTracker = "data";
continue;
} elseif( $indexTracker == "data" and ereg( "^DATE,BLOCKS", $lineInfo ) ) {
continue;
} elseif( ereg( "^---END DATA---", $lineInfo ) ) {
$indexTracker = "done";
continue;
}
/*
// here we deal with header data
*/
if( $indexTracker == "header" ) {
list( $dataName, $dataValue ) = explode( "=", $lineInfo );
switch( $dataName ) {
case "ID":
$this->dnetNumber = $dataValue;
break;
case "PARTICIPANT":
$this->dnetName = $dataValue;
break;
case "LASTUPDATE":
$this->dateYesterday = strtotime( str_replace( "-", " ", $dataValue ) );
break;
}
/*
// here we deal with blocks data
*/
} elseif( $indexTracker == "data" ) {
list( $date, $blocks ) = explode( ",", $lineInfo );
list( $m, $d, $y ) = explode( "/", $date );
$date = mktime( 1, 1, 1, $m, $d, $y );
if( empty( $this->dateFirst ) ) {
$this->dateFirst = $date;
$this->blocksFirst = $blocks;
}
$this->dateLast = $date;
$this->blocksLast = $blocks;
if( $this->dateYesterday = $this->dateLast ) {
$this->blocksYesterday = $this->blocksLast;
}
$this->blocksTotal += $blocks;
$this->dateTotal++;
if( $blocks > $this->blocksBest ) {
$this->blocksBest = $blocks;
$this->dateBest = $date;
}
} elseif( $indexTracker == "done" ) {
$this->blocksAverage = $this->blocksTotal/$this->dateTotal;
$this->dnetStatsDown = FALSE;
/*
// if we connected to stats box but didn't get a raw stats file, show an error
*/
} else /* $indexTracker == "" */ {
print( "<h2><font color=\"#ff0000\">Statsbox sent me gibberish!</font></h2>\n" );
$this->dnetStatsDown = TRUE;
}
}
/*
// if we didn't connect to stats box, show an error
*/
} else {
print( "<h2><font color=\"#ff0000\">Can't connect to the stats box!</font></h2>\n" );
$this->dnetStatsDown = TRUE;
}
}
/*
// end constructor function
*/
/*
// this is the function designed to be used in html files.
// a call will look like this: <?php echo $guy->show( BlocksTotal ) ?>
*/
function show( $whichValue ) {
if( $this->dnetStatsDown ) {
return "N/A";
}
switch( $whichValue ) {
case "DnetMemberNumber":
return $this->dnetNumber;
break;
case "DnetMemberName":
return $this->dnetName;
break;
case "DnetStatsURL":
return $this->dnetBaseURL.$this->dnetContest.$this->dnetStatsURL;
break;
case "DnetRawURL":
return $this->dnetBaseURL.$this->dnetContest.$this->dnetRawURL;
break;
case "BlocksFirstDay":
return $this->blocksFirst;
break;
case "BlocksLastDay":
return $this->blocksLast;
break;
case "BlocksYesterday":
return $this->blocksYesterday;
break;
case "BlocksTotal":
return $this->blocksTotal;
break;
case "BlocksBestDay":
return $this->blocksBest;
break;
case "BlocksAverage":
return $this->blocksAverage;
break;
case "KeysFirstDay":
return $this->blocksFirst * 268435456;
break;
case "KeysLastDay":
return $this->blocksLast * 268435456;
break;
case "KeysYesterday":
return $this->blocksYesterday * 268435456;
break;
case "KeysTotal":
return $this->blocksTotal * 268435456;
break;
case "KeysBestDay":
return $this->blocksBest * 268435456;
break;
case "KeysAverage":
return $this->blocksAverage * 268435456;
break;
case "KKeysFirstDay":
return $this->blocksFirst * 262144;
break;
case "KKeysLastDay":
return $this->blocksLast * 262144;
break;
case "KKeysYesterday":
return $this->blocksYesterday * 262144;
break;
case "KKeysTotal":
return $this->blocksTotal * 262144;
break;
case "KKeysBestDay":
return $this->blocksBest * 262144;
break;
case "KKeysAverage":
return $this->blocksAverage * 262144;
break;
case "MKeysFirstDay":
return $this->blocksFirst * 256;
break;
case "MKeysLastDay":
return $this->blocksLast * 256;
break;
case "MKeysYesterday":
return $this->blocksYesterday * 256;
break;
case "MKeysTotal":
return $this->blocksTotal * 256;
break;
case "MKeysBestDay":
return $this->blocksBest * 256;
break;
case "MKeysAverage":
return $this->blocksAverage * 256;
break;
case "RateFirstDay":
return round( $this->blocksFirst * 3106.89 );
break;
case "RateLastDay":
return round( $this->blocksLast * 3106.89 );
break;
case "RateYesterday":
return round( $this->blocksYesterday * 3106.89 );
break;
case "RateBestDay":
return round( $this->blocksBest * 3106.89 );
break;
case "RateAverage":
return round( $this->blocksAverage * 3106.89 );
break;
case "KRateFirstDay":
return round( $this->blocksFirst * 3.10689 );
break;
case "KRateLastDay":
return round( $this->blocksLast * 3.10689 );
break;
case "KRateYesterday":
return round( $this->blocksYesterday * 3.10689 );
break;
case "KRateBestDay":
return round( $this->blocksBest * 3.10689 );
break;
case "KRateAverage":
return round( $this->blocksAverage * 3.10689 );
break;
case "FirstDay":
return date( $this->dateStyle, $this->dateFirst );
break;
case "LastDay":
return date( $this->dateStyle, $this->dateLast );
break;
case "TotalDays":
return date( $this->dateTotal );
break;
case "Yesterday":
return date( $this->dateStyle, $this->dateYesterday );
break;
case "BestDay":
return date( $this->dateStyle, $this->dateBest );
break;
default:
return "Invalid Category Choice";
break;
}
}
/*
// end show() function
*/
/*
// this is the other function designed to be used in html files.
// a call will look like this: <?php echo $guy->showAll() ?>
*/
function showAll() {
if( $this->statsDown ) {
return "N/A";
}
$allArray = array( "Member Number"=>"DnetMemberNumber","Member Name"=>"DnetMemberName",
"URL to Stats"=>"DnetStatsURL","URL of Raw Stats"=>"DnetRawURL",
"Blocks Returned First Day"=>"BlocksFirstDay","Blocks Returned Last Day"=>"BlocksLastDay",
"Blocks Returned Yesterday"=>"BlocksYesterday","Total Blocks Returned"=>"BlocksTotal",
"Blocks Returned on Best Day"=>"BlocksBestDay","Average Blocks"=>"BlocksAverage",
"Keys Completed First Day"=>"KeysFirstDay","Keys Completed Last Day"=>"KeysLastDay",
"Keys Completed Yesterday"=>"KeysYesterday","Total Keys Completed"=>"KeysTotal",
"Keys Completed on Best Day"=>"KeysBestDay","Average Keys Completed"=>"KeysAverage",
"Kilo-Keys Completed First Day"=>"KKeysFirstDay","Kilo-Keys Completed Last Day"=>"KKeysLastDay",
"Kilo-Keys Completed Yesterday"=>"KKeysYesterday","Total Kilo-Keys Completed"=>"KKeysTotal",
"Kilo-Keys Completed on Best Day"=>"KKeysBestDay","Average Kilo-Keys Completed"=>"KKeysAverage",
"Mega-Keys Completed First Day"=>"MKeysFirstDay","Mega-Keys Completed Last Day"=>"MKeysLastDay",
"Mega-Keys Completed Yesterday"=>"MKeysYesterday","Total Mega-Keys Completed"=>"MKeysTotal",
"Mega-Keys Completed on Best Day"=>"MKeysBestDay","Average Mega-Keys Completed"=>"MKeysAverage",
"First Day Rate"=>"RateFirstDay","Last Day Rate"=>"RateLastDay","Yesterday's Rate"=>"RateYesterday",
"Best Days Rate"=>"RateBestDay","Average Rate"=>"RateAverage",
"Average Kilo-Rate of First Day"=>"KRateFirstDay","Kilo-Rate of Last Day"=>"KRateLastDay",
"Kilo-Rate of Yesterday"=>"KRateYesterday","Kilo-Rate of Best Day"=>"KRateBestDay",
"Average Kilo-Rate"=>"KRateAverage","First Day"=>"FirstDay","Last Day"=>"LastDay",
"Best Day"=>"BestDay","Number of Days Active"=>"TotalDays","Yesterday"=>"Yesterday"
);
$outputTable = "<table align=\"center\" border=\"3\" cellpadding=\"5\" cellspacing=\"0\">\n";
$outputTable .= "<tr><td colspan=\"2\" align=\"center\">\n";
$outputTable .= "Stats for ".$this->show( DnetMemberName )."<br>\n";
$outputTable .= "distributed.net id number: ".$this->show( DnetMemberNumber )."<br>\n";
$outputTable .= "as of ".$this->show( Yesterday )."</td></tr>\n";
while( list( $key, $value ) = each( $allArray ) ) {
$outputTable .= " <tr><td align=\"right\">".$key."</td><td align=\"left\">".$this->show( $value )."</td></tr>\n";
}
$outputTable .= "</table>\n";
return $outputTable;
}
/*
// end showAll() function
*/
}
/*
// end rawhide class
*/
?> |