aboutsummaryrefslogtreecommitdiff
path: root/h-source/Application/Include/hardware.php
blob: 67c77d4118022d0613503d1988d2cc37049c077b (plain) (blame)
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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
<?php

// h-source, a web software to build a community of people that want to share their hardware information.
// Copyright (C) 2010  Antonio Gallo (h-source-copyright.txt)
//
// This file is part of h-source
//
// h-source is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// h-source is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with h-source.  If not, see <http://www.gnu.org/licenses/>.

if (!defined('EG')) die('Direct access not allowed!');


function translate($string)
{
	return Hardware::translate($string);
}

class Hardware
{

	public static $translations = array(
		"amd64"		=>	'x86-64/amd64',
		"PC-Card"	=>	'PCMCIA/PC-Card',
		"works_with_3D"		=>	"works with 3D acceleration",
		"works_without_3D"	=>	"works, but without 3D acceleration",
		"does_not_work"		=>	"it does not work",
	);

	public static $regExpressions = array(
		"kernel"	=>	"/^[a-zA-Z0-9\-\_\.\+\s\(\)\,]+$/",
		"driver"	=>	"/^[a-zA-Z0-9\-\_\.\+\s\/\,\:\;\(\)\[\]]+$/",
		"vendorid_productid"	=>	"/^[a-zA-Z0-9]{4}(\:)[a-zA-Z0-9]{4}$/",
		"model"		=>	"/^[a-zA-Z0-9\-\_\.\+\s\(\)\@\[\]\/\,\']+$/",
	);

	public static function translate($string)
	{
		if (array_key_exists($string,self::$translations))
		{
			return self::$translations[$string];
		}
		return $string;
	}
	
	//classId => controller
	public static $deviceClasses = array(
		'0403'	=>	'soundcards',
		'0280'	=>	'wifi',
		'0300'	=>	'videocards',
		'0200'	=>	'ethernetcards',
		'0400'	=>	'acquisitioncards',
		'0401'	=>	'acquisitioncards',
		'0480'	=>	'acquisitioncards',
		'0805'	=>	'sdcardreaders',
		'0703'	=>	'modems',
		'0104'	=>	'raidadapters',
	);

	public static $icons = array(
		'notebook'				=>	'H2O/computer-laptop_22.png',
		'wifi'					=>	'H2O/network-wireless_22.png',
		'videocard'				=>	'Crystal/1282042976_hardware.png',
		'printer'				=>	'H2O/printer_22.png',
		'scanner'				=>	'H2O/scanner_22.png',
		'3G-card'				=>	'Crystal/usb_22.png',
		'soundcard'				=>	'H2O/audio-card_22.png',
		'webcam'				=>	'H2O/camera-web_22.png',
		'bluetooth'				=>	'H2O/preferences-system-bluetooth-22.png',
		'acquisition-card'		=>	'Crystal/cam_mount-22.png',
		'fingerprint-reader'	=>	'fingerprint_icon-22.png',
		'ethernet-card'			=>	'H2O/network-wired_22.png',
		'sd-card-reader'		=>	'H2O/media-flash-sd-mmc_22.png',
		'modem'					=>	'Crystal/modem_22.png',
		'RAID-adapter'			=>	'Crystal/1282042976_hardware.png',
		'PCMCIA-controller'		=>	'Crystal/1282042976_hardware.png',
	);

	public static $typeToController = array(
		'notebook'				=>	'notebooks',
		'wifi'					=>	'wifi',
		'videocard'				=>	'videocards',
		'printer'				=>	'printers',
		'scanner'				=>	'scanners',
		'3G-card'				=>	'threegcards',
		'soundcard'				=>	'soundcards',
		'webcam'				=>	'webcams',
		'bluetooth'				=>	'bluetooth',
		'acquisition-card'		=>	'acquisitioncards',
		'fingerprint-reader'	=>	'fingerprintreaders',
		'ethernet-card'			=>	'ethernetcards',
		'sd-card-reader'		=>	'sdcardreaders',
		'modem'					=>	'modems',
		'RAID-adapter'			=>	'raidadapters',
		'PCMCIA-controller'		=>	'pcmcia',
	);

	public static function getTypes()
	{
		return implode(',',array_keys(self::$typeToController));
	}
	
	public static function getControllerFromType($type)
	{
		if (array_key_exists($type,self::$typeToController))
		{
			return self::$typeToController[$type];
		}
		return null;
	}

	//get the type from the controller
	public static function getTypeFromController($controller)
	{
		$temp = array_flip(self::$typeToController);
		if (array_key_exists($controller,$temp))
		{
			return $temp[$controller];
		}
		return null;
	}

	public static function getTypeFromClass($class)
	{
		if (array_key_exists($class,self::$deviceClasses))
		{
			return self::getTypeFromController(self::$deviceClasses[$class]);
		}
		return null;
	}

	public static function getIconFromType($type)
	{
		if (array_key_exists($type,self::$icons))
		{
			return "http://".DOMAIN_NAME."/Public/Img/".self::$icons[$type];
		}
		return null;
	}

	public static function getIconFromController($controller)
	{
		if ($type = self::getTypeFromController($controller))
		{
			return self::getIconFromType($type);
		}
		return null;
	}

	public static function getIconFromClass($class)
	{
		if (array_key_exists($class,self::$deviceClasses))
		{
			return self::getIconFromController(self::$deviceClasses[$class]);
		}
		return null;
	}

	//get the list of the allowed years of commercialization
	public static function getCommYears()
	{
		$currentYear = (int)date("Y");
		$allowed = 'not-specified';
		
		for ($i=$currentYear;$i>1991;$i--)
		{
			$allowed .= ",$i";
		}
		return $allowed;
	}

	public static $trackSelect = 'not-specified,no,yes';

}

class Printer extends Hardware
{

	public static $compatibility = array(
		"A-Full" 		=>	"A-Full",
		"B-Partial"		=>	"B-Partial",
		"C-None"		=>	"C-None",
	);
	
	public static $interface = "not-specified,USB,Serial,Parallel,Firewire,SCSI,Ethernet";
	
	public static $subtype = "not-specified,laser,inkjet,other";

	public static function compatibilityList()
	{
		return implode(',',array_values(self::$compatibility));
	}
	
}

class Wifi extends Hardware
{

	public static $interface = array(
		"not-specified"	 	=>	"not-specified",
		"USB"				=>	"USB",
		"PCI"				=>	"PCI",
		"PCI-E"				=>	"PCI-E",
		"mini-PCI"			=>	"mini-PCI",
		"mini-PCI-E"		=>	"mini-PCI-E",
		"ExpressCard"		=>	"ExpressCard",
		"Ethernet"			=>	"Ethernet",
		"PCMCIA/PC-Card"	=>	"PC-Card",
	);
	
	public static $interfaceReverse = array(
		"not-specified"	 	=>	"not-specified",
		"USB"				=>	"USB",
		"PCI"				=>	"PCI",
		"PCI-E"				=>	"PCI-E",
		"mini-PCI"			=>	"mini-PCI",
		"mini-PCI-E"		=>	"mini-PCI-E",
		"ExpressCard"		=>	"ExpressCard",
		"Ethernet"			=>	"Ethernet",
		"PC-Card"			=>	"PCMCIA/PC-Card",
	);
	
	public static $wifiSelect = 'yes,no';
	
	public static function interfaceList()
	{
		return implode(',',array_values(self::$interface));
	}
}

class Videocard extends Hardware
{

	public static $videoSelect = array(
		"works with 3D acceleration" 				=>	"works_with_3D",
		"works, but without 3D acceleration"		=>	"works_without_3D",
		"it does not work"							=>	"does_not_work",
	);
	
	public static $videoReverse = array(
		"works_with_3D"		=>	"works with 3D acceleration",
		"works_without_3D"	=>	"works, but without 3D acceleration",
		"does_not_work"		=>	"it does not work",
	);
	
	public static $interface = "not-specified,PCI,AGP,PCI-E,ISA,MCA,VLB";
	
	public static function videoList()
	{
		return implode(',',array_values(self::$videoSelect));
	}
}


class Notebooks extends Hardware
{
	
	public static $vendors = array(
		"Acer"					=>	"Acer",
		"Apple"					=>	"Apple",
		"Asus"					=>	"Asus",
		"Blue Light"			=>	"Blue-Light",
		"CLEVO CO."				=>	"CLEVO-CO",
		"Compal Electronics"	=>	"Compal-Electronics",
		"COMPAQ"				=>	"COMPAQ",
		"Dell"					=>	"Dell",
		"emachines"				=>	"emachines",
		"FUJITSU"				=>	"FUJITSU",
		"Garlach44"				=>	"Garlach44",
		"Gateway"				=>	"Gateway",
		"Hewlett Packard" 		=>	"Hewlett-Packard",
		"IBM" 					=>	"IBM",
		"Lanix"					=>	"Lanix",
		"Lemote"				=>	"Lemote",
		"Lenovo"				=>	"Lenovo",
		"LG"					=>	"LG",
		"msi"					=>	"msi",
		"One Laptop per Child (Non-Profit)"	=>	"One-Laptop-per-Child-Non-Profit",
		"Philco"				=>	"Philco",
		"Philips"				=>	"Philips",
		"Panasonic"				=>	"Panasonic",
		"SAMSUNG"				=>	"SAMSUNG",
		"Sony"					=>	"Sony",
		"System76"				=>	"System76",
		"Thomson"				=>	"Thomson",
		"TOSHIBA"				=>	"TOSHIBA",
		"ZaReason, Inc"			=>	"ZaReason-Inc",
	);

	public static $compatibility = array(
		"A Platinum" 			=>	"A-platinum",
		"B Gold"				=>	"B-gold",
		"C Silver"				=>	"C-silver",
		"D Bronze"				=>	"D-bronze",
		"E Garbage"				=>	"E-garbage"
	);
	
	public static $subtypeSelect = 'notebook,netbook,motherboard,tablet,not-specified';

	public static $architectureSelect = array(
		"not specified"			=>	'not-specified',
		"x86"					=>	'x86',
		"x86-64/amd64"			=>	'amd64',
		"MIPS"					=>	'MIPS',
		"ARM"					=>	'ARM',
	);
	
	public static $biosSelect = array(
		"not specified"		=>	'not-specified',
		"no"				=>	'no',
		"yes"				=>	'yes'
	);

	public static $installableSelect = 'not-specified,no,yes';
	
	public static $videoSelect = array(
		"not specified"							=>	'not-specified',
		"yes, with 3D acceleration" 			=>	"yes_with_3D",
		"yes, but without 3D acceleration"		=>	"yes_without_3D",
		"it does not work"						=>	"no",
	);

	public static $videoReverse = array(
		"yes_with_3D"		=>	"works with 3D acceleration",
		"yes_without_3D"	=>	"works but without 3D acceleration",
		"no"				=>	"it does not work",
		'not-specified'		=>	"not specified how it works",
		""					=>	""
	);
	
	public static $wifiSelect = array(
		"not specified"			=>	'not-specified',
		'yes'					=>	'yes',
		'no'					=>	'no',
		'there is no wifi card'	=>	'no-wifi-card',
	);
	
	public static $wifiReverse = array(
		"yes"			=>	"it works",
		"no"			=>	"it does not work",
		'not-specified'	=>	"not specified how it works",
		'no-wifi-card'	=>	'there is no wifi card',
		""				=>	""
	);
	
	public static $webcamSelect = array(
		'not specified'			=>	'not-specified',
		'it works'				=>	'yes',
		'it does not work'		=>	'no',
		'there is no webcam'	=>	'there-is-no-webcam',
	);
	
	public static $webcamReverse = array(
		"yes"					=>	"it works",
		"no"					=>	"it does not work",
		'not-specified'			=>	"not specified how it works",
		'there-is-no-webcam'	=>	'there is no webcam',
	);
	
	public static function videoList()
	{
		return implode(',',array_values(self::$videoSelect));
	}

	public static function wifiList()
	{
		return implode(',',array_values(self::$wifiSelect));
	}
	
	public static function webcamList()
	{
		return implode(',',array_values(self::$webcamSelect));
	}
	
	public static function vendorsList()
	{
		return implode(',',array_values(self::$vendors));
	}
	
	public static function compatibilityList()
	{
		return implode(',',array_values(self::$compatibility));
	}

	public static function architectureList()
	{
		return implode(',',array_values(self::$architectureSelect));
	}
	
	public static function biosList()
	{
		return implode(',',array_values(self::$biosSelect));
	}
}

class ThreeGcards extends Wifi
{

	public static $select = 'yes,no';


}

class Soundcards extends Hardware
{

	public static $audioSelect = 'yes,no';
	
	public static $interface = "not-specified,PCI,ISA,USB,Firewire,Parallel,PCI-E,PCMCIA";

}

class Webcams extends Hardware
{

	public static $select = 'yes,no';

	public static $interface = "not-specified,USB,Firewire,Parallel,Wifi,Serial";

}

class Bluetooth extends Hardware
{

	public static $select = 'yes,no';

	public static $interface = "not-specified,USB,PCI,PCI-E,mini-PCI,mini-PCI-E,ExpressCard,PC-Card";

}

class Acquisitioncards extends Hardware
{

	public static $select = 'yes,no';

	public static $interface = "not-specified,USB,PCI,PCI-E,mini-PCI,mini-PCI-E,ExpressCard,PC-Card,Firewire,Parallel,Serial";

}

class Fingerprintreaders extends Acquisitioncards
{

}

class Ethernetcards extends Acquisitioncards
{

}

class Sdcardreaders extends Acquisitioncards
{

}

class Modems extends Acquisitioncards
{

}

class Raidadapters extends Acquisitioncards
{

}

class PCMCIAControllers extends Acquisitioncards
{

}