Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
182 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
class stdObject { | ||
public function __construct(array $arguments = array()) { | ||
if (!empty($arguments)) { | ||
foreach ($arguments as $property => $argument) { | ||
$this->{$property} = $argument; | ||
} | ||
} | ||
} | ||
|
||
public function __call($method, $arguments) { | ||
$arguments = array_merge(array("stdObject" => $this), $arguments); // Note: method argument 0 will always referred to the main class ($this). | ||
if (isset($this->{$method}) && is_callable($this->{$method})) { | ||
return call_user_func_array($this->{$method}, $arguments); | ||
} else { | ||
throw new Exception("Fatal error: Call to undefined method stdObject::{$method}()"); | ||
} | ||
} | ||
} | ||
|
||
function REQUEST_IS_POST() { | ||
return isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD']=='POST'; | ||
} | ||
|
||
function VALIDATE_REQUEST() { | ||
return $_POST['fingerprint'] != '' && | ||
'' != $_POST['type'] && | ||
'' != $_POST['os_vers'] && | ||
'' != $_POST['os_build'] && | ||
'' != $_POST['productname'] && | ||
'' != $_POST['webkit_vers'] && | ||
'' != $_POST['safari_vers'] && | ||
'' != $_POST['locale'] && | ||
'' != $_POST['timezone']; | ||
} | ||
|
||
try { | ||
if (REQUEST_IS_POST() && VALIDATE_REQUEST()){ | ||
|
||
$device = new stdObject(); | ||
|
||
function sanitize_input($data) { | ||
$data = trim($data); | ||
$data = stripslashes($data); | ||
$data = htmlspecialchars($data); | ||
return $data; | ||
} | ||
|
||
$device->fingerprint = sanitize_input($_POST['fingerprint']); | ||
$device->type = sanitize_input($_POST['type']); | ||
$device->productname = sanitize_input($_POST['productname']); | ||
$device->os_vers = sanitize_input($_POST['os_vers']); | ||
$device->os_build = sanitize_input($_POST['os_build']); | ||
$device->webkit_vers = sanitize_input($_POST['webkit_vers']); | ||
$device->safari_vers = sanitize_input($_POST['safari_vers']); | ||
$device->locale = sanitize_input($_POST['locale']); | ||
$device->timezone = sanitize_input($_POST['timezone']); | ||
$device->submission_time = round(microtime(true) * 1000); | ||
|
||
$data = file_get_contents('devices.json'); | ||
$data = json_decode($data_old, true); | ||
$data[] = $device; | ||
$data_new = json_encode($data); | ||
$fp = fopen('devices.json', 'a+'); | ||
fwrite($fp, $data_new); | ||
fclose($fp); | ||
header('Content-Type: application/json'); | ||
echo $data_new; | ||
} | ||
} catch(Exception $e) { | ||
echo 'Oops something seems to have gone wrong: '.$e->getMessage().'\n'; | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
//Function for freeing an object on the window, well sortof. | ||
var JSFree = function(obj) { | ||
window[obj] = undefined; | ||
}; | ||
}; | ||
|
||
var JSAlloc = function size(name, size) { | ||
if(typeof eval('window.'+name) !== 'undefined') return false; | ||
eval('window.'+name+'=new Array('+size+');'); | ||
}; | ||
|
||
free = JSFree; | ||
malloc = JSAlloc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.