2 define('HIDDEN_DATABASE_FILE_NAME', './customers.csv');
3 $file=fopen(HIDDEN_DATABASE_FILE_NAME, 'a');
4 if($file===FALSE)exit(1);
5 define('TOKEN_CSV', '|');
6 define('ENTRY_SEPARATOR', "\n");
7 define('NAME_LENGTH', 30);
8 define('EMAIL_LENGTH', 40);
9 define('GROUP_LENGTH', 30);
10 define('OS_LENGTH', 20);
11 define('VV_VERSION_LENGTH', 30);
12 define('COUNTRY_LENGTH', 30);
13 define('ARCHITECTURE_LENGTH',10);
14 define('ADRESSING_LENGTH',10);
15 define('COMPILATION_DATE_LENGTH', 30);
16 function ensureString($var, $length){
17 $var = str_replace("\n", '',$var);
18 $var = str_replace(TOKEN_CSV, '', $var);
19 return substr($var, 0, $length);
21 function writeLine($file, $data){
22 fwrite($file, implode(TOKEN_CSV, $data).ENTRY_SEPARATOR);
24 $data['name'] = ensureString($_GET['name'], NAME_LENGTH);
25 $data['lastname'] = ensureString($_GET['lastName'], NAME_LENGTH);
26 $data['email'] = ensureString($_GET['email'], EMAIL_LENGTH);
27 $data['group'] = ensureString($_GET['group'], GROUP_LENGTH);
28 $data['ip'] = $_SERVER['REMOTE_ADDR'];
29 $data['os'] = ensureString($_GET['os'], OS_LENGTH);
30 $data['vvVersion']= ensureString($_GET['vvVersion'], VV_VERSION_LENGTH);
31 $data['time'] = date("F j, Y, g:i a");
32 $data['geoloc'] = ensureString(file_get_contents('http://api.hostip.info/country.php?ip='.$_SERVER['REMOTE_ADDR']), COUNTRY_LENGTH);
33 $data['architecture'] = ensureString($_GET['architecture'], ARCHITECTURE_LENGTH);
34 $data['adressing'] = ensureString($_GET['adressing'], ADRESSING_LENGTH);
35 $data['compilationDate'] = ensureString($_GET['compilationDate'], COMPILATION_DATE_LENGTH);
36 writeLine($file, $data);