Data.class.php 971 Bytes
Newer Older
Orbmancer's avatar
Orbmancer committed
1
2
3
4
5
<?php

class Data {

    public static function saveXML($data, $name, $x, $y, $TD = 1){
Erwan Normand's avatar
Erwan Normand committed
6
7
8
		$file = 'data/td'.$TD.'/'.$x.'_'.$y.'-'.$name.'.vvvvvv';
        if (!file_put_contents($file, $data)) {
             trigger_error('Cannot save the vvvvvv file : ' . $file, E_USER_ERROR);
Orbmancer's avatar
Orbmancer committed
9
        }
Erwan Normand's avatar
Erwan Normand committed
10
		return true;
Orbmancer's avatar
Orbmancer committed
11
12
13
14
15
16
17
18
19
20
21
    }

    public static function loadXML($TD){
        $output = array();
        $dir = 'data/td'.$TD.'/';

        if ($handle = opendir($dir)) {

            while (false !== ($entry = readdir($handle))) {

                if ($entry != "." && $entry != "..") {
22
23
24
25
26
27
28
29

                    $x = substr($entry, 0, 1);
                    $y = substr($entry, 2, 1);
                    $output[] = array(
                        'x' => $x,
                        'y' => $y,
                        'content' =>file_get_contents($dir.$entry)
                    );
Orbmancer's avatar
Orbmancer committed
30
31
32
33
34
35
36
37
38
                }
            }

            closedir($handle);
        }

        return $output;
    }
}