-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathconv.php
More file actions
39 lines (31 loc) · 664 Bytes
/
conv.php
File metadata and controls
39 lines (31 loc) · 664 Bytes
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
<?php
if (php_sapi_name() != 'cli')
{
die("This script works on cli only.");
}
if ($argc != 4)
{
echo "Usage: \n";
echo "php conv.php filename outputfile javascriptname\n";
echo "Filename: File to convert to a javascript Array\n";
echo "Outputfile: File to save the javascript Array\n";
echo "Javascriptname: The javascript variable name the data is saved in\n";
exit;
}
$var = $argv[3];
$open = $argv[1];
$save = $argv[2];
$rs = @fopen ($open, 'r+');
if (!$rs)
{
die("Coulnt open $open.");
}
$tmp = "window.{$var} = [";
while (!feof ($rs))
{
$val = fread($rs, 1);
$tmp .= ord($val);
$tmp .= ",";
}
$tmp .= "]";
file_put_contents($save, $tmp);