]> git.vanrenterghem.biz Git - www.vanrenterghem.biz.git/blob - phpBB2_old/admin/xs_include_import.php
Baseline
[www.vanrenterghem.biz.git] / phpBB2_old / admin / xs_include_import.php
1 <?php
3 /***************************************************************************
4  *                           xs_include_import.php
5  *                           ---------------------
6  *   copyright            : (C) 2003, 2004 CyberAlien
7  *   support              : http://www.phpbbstyles.com
8  *
9  *   version              : 2.0.1
10  *
11  *   file revision        : 10
12  *   project revision     : 51
13  *   last modified        : 25 Aug 2004  11:51:48
14  *
15  ***************************************************************************/
17 /***************************************************************************
18  *
19  *   This program is free software; you can redistribute it and/or modify
20  *   it under the terms of the GNU General Public License as published by
21  *   the Free Software Foundation; either version 2 of the License, or
22  *   (at your option) any later version.
23  *
24  ***************************************************************************/
26 if (!defined('IN_PHPBB') || !defined('IN_XS'))
27 {
28         die("Hacking attempt");
29 }
32 function generate_actions_files($dir)
33 {
34         global $items;
35         // remove trailing /
36         $pos = strrpos($dir, '/');
37         $dir = $pos === strlen($dir) - 1 ? substr($dir, 0, $pos) : $dir;
38         $arr = array('processing: '.$dir);
39         for($i=0; $i<count($items); $i++)
40         {
41                 if($items[$i]['dir'] === $dir)
42                 {
43                         $arr[] = array(
44                                 'command'       => 'upload',
45                                 'local'         => $items[$i]['tmp'],
46                                 'remote'        => $items[$i]['file']
47                                 );
48                 }
49         }
50         return $arr;
51 }
53 function generate_actions_dirs($dir = '')
54 {
55         global $dirs;
56         $arr = array();
57         if($dir && substr($dir, strlen($dir) - 1) !== '/')
58         {
59                 $dir .= '/';
60         }
61         if($dir)
62         {
63                 // remove trailing /
64                 $pos = strrpos($dir, '/');
65                 $str = $pos === strlen($dir) - 1 ? substr($dir, 0, $pos) : $dir;
66                 // get last directory name
67                 $pos = strrpos($str, '/');
68                 $str = $pos ? substr($str, $pos + 1) : $str;
69                 $arr[] = array(
70                         'command'       => 'mkdir',
71                         'dir'           => $str,
72                         'ignore'        => true
73                         );
74                 $arr[] = array(
75                         'command'       => 'chdir',
76                         'dir'           => $str
77                         );
78         }
79         $arr[] = array(
80                 'command'       => 'exec',
81                 'list'          => generate_actions_files($dir)
82                 );
83         // create subdirectories
84         $len = strlen($dir);
85         for($i=0; $i<count($dirs); $i++)
86         {
87                 $str = $dirs[$i];
88                 if(substr($str, 0, $len) === $dir)
89                 {
90                         if($len)
91                         {
92                                 $str = substr($str, $len + 1);
93                         }
94                         $pos = strpos($str, '/');
95                         if($pos == strlen($str) - 1)
96                         {
97                                 $arr[] = array(
98                                                 'command'       => 'exec',
99                                                 'list'          => generate_actions_dirs($dirs[$i])
100                                         );
101                         }
102                 }
103         }
104         return $arr;
107 function generate_style_name($str)
109         $str = 'style_' . $str . '_%02d' . STYLE_EXTENSION;
110         $num = 0;
111         $found = true;
112         while($found)
113         {
114                 $filename = sprintf($str, $num);
115                 $found = @file_exists(XS_TEMP_DIR.$filename);
116                 $num ++;
117         }
118         return $filename;
121 ?>