[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare - Filemanager * 4 * http://www.egroupware.org * 5 * ------------------------------------------------------------------------ * 6 * This program is free software; you can redistribute it and/or modify it * 7 * under the terms of the GNU General Public License as published by the * 8 * Free Software Foundation; either version 2 of the License, or (at your * 9 * option) any later version. * 10 \**************************************************************************/ 11 12 /* $Id: class.bofilemanager.inc.php 19410 2005-10-14 10:41:15Z ralfbecker $ */ 13 14 class bofilemanager 15 { 16 // used 17 18 var $so; 19 var $vfs; 20 21 var $rootdir; 22 var $fakebase; 23 var $appname; 24 var $filesdir; 25 var $hostname; 26 var $userinfo = Array(); 27 var $homedir; 28 var $sep; 29 var $file_attributes; 30 31 var $matches;//FIXME matches not defined 32 33 var $debug = False; 34 35 function bofilemanager() 36 { 37 $this->so =& CreateObject('filemanager.sofilemanager'); 38 $this->so->db_init(); 39 40 $this->vfs =& CreateObject('phpgwapi.vfs'); 41 42 error_reporting(4); 43 44 ### Start Configuration Options ### 45 ### These are automatically set in eGW - do not edit ### 46 47 $this->sep = SEP; 48 $this->rootdir = $this->vfs->basedir; 49 $this->fakebase = $this->vfs->fakebase; 50 $this->appname = $GLOBALS['egw_info']['flags']['currentapp']; 51 52 if(stristr($this->rootdir, EGW_SERVER_ROOT)) 53 { 54 $this->filesdir = substr($this->rootdir, strlen(EGW_SERVER_ROOT)); 55 } 56 else 57 { 58 unset($this->filesdir); 59 } 60 61 $this->hostname = $GLOBALS['egw_info']['server']['webserver_url'] . $this->filesdir; 62 63 // die($this->hostname); 64 ### 65 # Note that $userinfo["username"] is actually the id number, not the login name 66 ### 67 68 $this->userinfo['username'] = $GLOBALS['egw_info']['user']['account_id']; 69 $this->userinfo['account_lid'] = $GLOBALS['egw']->accounts->id2name($this->userinfo['username']); 70 $this->userinfo['hdspace'] = 10000000000; // to settings 71 $this->homedir = $this->fakebase.'/'.$this->userinfo['account_lid']; 72 73 ### End Configuration Options ### 74 75 if(!defined('NULL')) 76 { 77 define('NULL', ''); 78 } 79 80 ### 81 # Define the list of file attributes. Format is "internal_name" => "Displayed name" 82 # This is used both by internally and externally for things like preferences 83 ### 84 85 $this->file_attributes = Array( 86 'name' => lang('File Name'), 87 'mime_type' => lang('MIME Type'), 88 'size' => lang('Size'), 89 'created' => lang('Created'), 90 'modified' => lang('Modified'), 91 'owner' => lang('Owner'), 92 'createdby_id' => lang('Created by'), 93 'modifiedby_id' => lang('Created by'), 94 'modifiedby_id' => lang('Modified by'), 95 'app' => lang('Application'), 96 'comment' => lang('Comment'), 97 'version' => lang('Version') 98 ); 99 } 100 101 ### 102 # Calculate and display B or KB 103 # And yes, that first if is strange, 104 # but it does do something 105 ### 106 function borkb($size, $enclosed = NULL, $return = 1) 107 { 108 if(!$size) 109 { 110 $size = 0; 111 } 112 113 if($enclosed) 114 { 115 $left = '('; 116 $right = ')'; 117 } 118 119 if($size < 1024) 120 { 121 $rstring = $left . $size . 'B' . $right; 122 } 123 else 124 { 125 $rstring = $left . round($size/1024) . 'KB' . $right; 126 } 127 128 return($this->eor($rstring, $return)); 129 } 130 131 ### 132 # Check for and return the first unwanted character 133 ### 134 135 function bad_chars($string, $all = True, $return = 0) 136 { 137 if($all) 138 { 139 if(preg_match("-([\\/<>\'\"\&])-", $string, $badchars)) 140 { 141 $rstring = $badchars[1]; 142 } 143 } 144 else 145 { 146 if(preg_match("-([\\/<>])-", $string, $badchars)) 147 { 148 $rstring = $badchars[1]; 149 } 150 } 151 152 return trim(($this->eor($rstring, $return))); 153 } 154 155 ### 156 # Match character in string using ord(). 157 ### 158 159 function ord_match($string, $charnum) 160 { 161 for($i = 0; $i < strlen($string); $i++) 162 { 163 $character = ord(substr($string, $i, 1)); 164 165 if($character == $charnum) 166 { 167 return True; 168 } 169 } 170 171 return False; 172 } 173 174 ### 175 # Decide whether to echo or return. Used by HTML functions 176 ### 177 178 function eor($rstring, $return) 179 { 180 if($return) 181 { 182 return($rstring); 183 } 184 else 185 { 186 $this->html_text($rstring . "\n"); 187 return(0); 188 } 189 } 190 191 function html_text($string, $times = 1, $return = 0, $lang = 0) 192 { 193 if($lang) 194 { 195 $string = lang($string); 196 } 197 198 if($times == NULL) 199 { 200 $times = 1; 201 } 202 for($i = 0; $i != $times; $i++) 203 { 204 if($return) 205 { 206 $rstring .= $string; 207 } 208 else 209 { 210 echo $string; 211 } 212 } 213 if($return) 214 { 215 return($rstring); 216 } 217 } 218 219 ### 220 # URL encode a string 221 # First check if its a query string, then if its just a URL, then just encodes it all 222 # Note: this is a hack. It was made to work with form actions, form values, and links only, 223 # but should be able to handle any normal query string or URL 224 ### 225 function string_encode($string, $return = False) 226 { 227 //var_dump($string); 228 if(preg_match("/=(.*)(&|$)/U", $string)) 229 { 230 $rstring = $string; 231 232 preg_match_all("/=(.*)(&|$)/U", $string, $matches, PREG_SET_ORDER);//FIXME matches not defined 233 234 reset($matches);//FIXME matches not defined 235 236 while(list(,$match_array) = each($matches))//FIXME matches not defined 237 { 238 $var_encoded = rawurlencode(base64_encode($match_array[1])); 239 $rstring = str_replace($match_array[0], '=' . $var_encoded . $match_array[2], $rstring); 240 } 241 } 242 elseif($this->hostname != "" && ereg('^'.$this->hostname, $string)) 243 // elseif(ereg('^'.$this->hostname, $string)) 244 { 245 $rstring = ereg_replace('^'.$this->hostname.'/', '', $string); 246 $rstring = preg_replace("/(.*)(\/|$)/Ue", "rawurlencode(base64_encode('\\1')) . '\\2'", $rstring); 247 $rstring = $this->hostname.'/'.$rstring; 248 } 249 else 250 { 251 $rstring = rawurlencode($string); 252 253 /* Terrible hack, decodes all /'s back to normal */ 254 $rstring = preg_replace("/%2F/", '/', $rstring); 255 } 256 257 return($this->eor($rstring, $return)); 258 } 259 260 function string_decode($string, $return = False) 261 { 262 $rstring = rawurldecode($string); 263 264 return($this->eor($rstring, $return)); 265 } 266 267 ### 268 # HTML encode a string 269 # This should be used with anything in an HTML tag that might contain < or > 270 ### 271 272 function html_encode($string, $return) 273 { 274 $rstring = htmlspecialchars($string); 275 276 return($this->eor($rstring, $return)); 277 } 278 } 279 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |