chengkun
2025-05-23 0d8e263c22903234efea68fd13a27d8b7b59aac1
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
 
 
 
class style
{
 
    function __construct($obj)
    {
        $this->obj = $obj;
    }
 
    /**
     * @desc 获取前台模板风格目录
     */
    function model_list_action()
    {
 
        $path   =   TPL_PATH;
        $handle =   @opendir($path);
 
        while ($file = @readdir($handle)) {
 
            if ($file == '.' || $file == '..' || $file == '.svn' || $file == 'member' || $file == 'train' || $file == 'school' || $file == 'siteadmin' || $file == 'admin' || $file == 'company' || $file == 'im' || $file == 'wap' || $file == 'lietou' || $file == 'ask' || $file == 'wapadmin' || $file == 'resume' || $file == 'chat') continue;
            if (is_dir($path . $file)) {
 
                $list[] = $file;
            }
        }
 
        if (isset($list) && is_array($list)) {
 
            foreach ($list as $key => $value) {
 
                $filepath   =   $path.$value.'/info.txt';
 
                if (!file_exists($filepath)) {
 
                    $fopen  =   @fopen($filepath, 'w+');
                    fclose($fopen);
                }
 
                $size       =   @filesize($filepath);
                $fp         =   @fopen($filepath, 'r+');
 
                $text       =   @fread($fp, $size);
                if ($text == '') {
 
                    $text   =   '暂未命名||暂无添加作者信息||' . $value . '||' . '../app/template/' . $value . '/images/preview.jpg';
                    @fwrite($fp, $text);
                }
                @fclose($fp);
 
                $content    =   @explode('||', $text);
                $text       =   '';
                $lists[$key]['name']    =   $content[0];
                $lists[$key]['author']  =   $content[1];
                $lists[$key]['dir']     =   $content[2];
                $lists[$key]['img']     =   $content[3];
            }
        }
        return $lists;
    }
 
    /**
     * @desc 获取风格信息修改
     * @param $dir
     * @return array
     */
    function model_modify_action($dir)
    {
        $path       =   TPL_PATH.$dir.'/info.txt';
        $fp         =   @fopen($path, r);
        $text       =   @fread($fp, filesize($path));
        @fclose($fp);
        $content    =   @explode('||', $text);
 
        return array('name' => $content[0], 'author' => $content[1], 'dir' => $content[2], 'img' => $content[3],);
 
    }
 
    /**
     * @param $arr
     */
    function model_save_action($arr)
    {
 
        $path   =   TPL_PATH.$arr['dir'].'/info.txt';
        $text   =   $arr['name'] . '||' . $arr['author'] . '||' . $arr['dir'] . '||../app/template/' . $arr['dir'] . '/images/preview.jpg';
        $fp     =   @fopen($path, w);
        @fwrite($fp, $text);
        @fclose($fp);
 
    }
 
}