-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSQMFile.php
More file actions
67 lines (61 loc) · 1.87 KB
/
SQMFile.php
File metadata and controls
67 lines (61 loc) · 1.87 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
<?php
/**
* Created by Ascendro S.R.L.
* User: Michael
* Date: 19.06.13
* Time: 08:44
*/
class SQMFile
{
const INPUTTYPE_FILENAME = 0x01;
const INPUTTYPE_STRING = 0x02;
const INPUTTYPE_RESSOURCE = 0x02;
public $path = "";
public $filename = "";
public $hash = "";
public $content = null;
public $parsedData = array();
public $player = array();
function SQMFile($file,$inputType = SQMFile::INPUTTYPE_FILENAME) {
switch ($inputType) {
case SQMFile::INPUTTYPE_FILENAME :
$this->path = $file;
$this->filename = basename($file);;
$this->content = fopen($file,"r");
break;
case SQMFile::INPUTTYPE_RESSOURCE :
$this->path = "RESSOURCE";
$this->filename = "";
$this->content = $file;
break;
case SQMFile::INPUTTYPE_STRING :
default:
$this->path = "STRING";
$this->filename = "";
$this->content = fopen("php://memory","r+");
fputs($this->content,$file,strlen($file));
break;
}
rewind($this->content);
$this->hash = md5(stream_get_contents($this->content));
rewind($this->content);
}
function parse() {
$this->parsedData = SQMParser::parse($this);
}
function searchPlayableSlots($reduce = false) {
$this->player = array();
if (!empty($this->parsedData)) {
$playerParser = new SQMPlayerParser($this);
$this->player = $playerParser->parse($reduce);
}
return $this->player;
}
public function __destruct()
{
if ($this->content) {
fclose($this->content);
$this->content = null;
}
}
}