This repository was archived by the owner on Mar 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
63 lines (55 loc) · 1.61 KB
/
Copy pathindex.php
File metadata and controls
63 lines (55 loc) · 1.61 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
<?php
$pathStatic='http://lglab.ru/xmlserver/static';
$dom = new DOMDocument('1.0', 'utf-8');
$gameServer = $dom->createElement('server');
$gameServer->setAttribute('admin', 'lexgorbunov@gmail.com');
$dom->appendChild($gameServer);
$game=$dom->createElement('game');
$game->setAttribute('name', 'stars');
$game->setAttribute('v', '1.0');
$gameServer->appendChild($game);
$images=$dom->createElement('images');
$game->appendChild($images);
$pathImg=$pathStatic.'/img';
$imgList=array();
$dir= dirname(__FILE__).'/static/img';
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if(!is_file($dir.'/'.$file))
continue;
$imgList[preg_replace('/(.*)\.[\w\d]+$/', '$1', $file)]=$pathImg.'/'.$file;
}
closedir($dh);
}
foreach ($imgList as $imgID=>$imgPath)
{
$imgNode=$dom->createElement('img');
$imgNode->setAttribute('id', $imgID);
$imgNode->setAttribute('url', $imgPath);
$images->appendChild($imgNode);
}
$sound=$dom->createElement('sound');
$game->appendChild($sound);
$pathSound=$pathStatic.'/sound';
$dir= dirname(__FILE__).'/static/sound';
$soundList=array();
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if(!is_file($dir.'/'.$file))
continue;
$soundList[preg_replace('/(.*)\.[\w\d]+$/', '$1', $file)]=$pathSound.'/'.$file;
}
closedir($dh);
}
foreach ($soundList as $soundID=>$soundPath)
{
$soundNode=$dom->createElement('track');
$soundNode->setAttribute('id', $soundID);
$soundNode->setAttribute('url', $soundPath);
$sound->appendChild($soundNode);
}
echo $dom->saveXML();