Project

General

Profile

« Previous | Next » 

Revision 1651

Added by darkviper over 12 years ago

fixed a little problem with chmod()

View differences:

branches/2.8.x/CHANGELOG
11 11
! = Update/Change
12 12
===============================================================================
13 13

  
14
26 Mar-2012 Build 1651 Werner v.d.Decken(DarkViper)
15
# fixed a little problem with chmod()
16
+ add argument 'replyTo' into class.wb::mail()
14 17
24 Mar-2012 Build 1650 Werner v.d.Decken(DarkViper)
15 18
+ add argument 'replyTo' into class.wb::mail()
16 19
24 Mar-2012 Build 1649 Dietmar Woellbrink (Luisehahne)
branches/2.8.x/wb/admin/skel/themes/htt/addons.htt
52 52
						</td>
53 53
					</tr>
54 54
					<tr>
55
						<td class="description" valign="top"><span class="title">{TXT_THEME_COPY_CURRENT}</span>
56
							{TXT_THEME_CURRENT}: {CURRENT_THEME}<br />
57
							<i>[{THEME_PATH}]</i><br />
55
						<td class="description" valign="top"><hr /><span class="title">{TXT_THEME_COPY_CURRENT}</span>
56
							{TXT_THEME_CURRENT}: <b>{CURRENT_THEME}</b><br />
57
							<i>[ {THEME_PATH} ]</i><br /><br />
58 58
							{MESSAGE_THEME_COPY_CURRENT}
59 59
							<br style="margin-bottom: 0.5em" />
60
							<label for="theme_newname">{TXT_THEME_NEW_NAME}: </label>
60 61
							<input type="text" id="theme_newname" name="ThNewTheme" value="{THEME_DEFAULT_NAME}" />
61
							<label for="theme_newname">{TXT_THEME_NEW_NAME}</label>
62 62
							<input type="submit" name="cmdCopyTheme" value="{TXT_THEME_START_COPY}" />
63 63
						</td>
64 64
					</tr>
65 65
					<tr>
66
						<td class="description" valign="top"><span class="title">{TXT_THEME_IMPORT_HTT}</span>
67
							{TXT_THEME_CURRENT}: {CURRENT_THEME}<br />
66
						<td class="description" valign="top"><hr /><span class="title">{TXT_THEME_IMPORT_HTT}</span>
67
							{TXT_THEME_CURRENT}: <b>{CURRENT_THEME}</b><br /><br />
68 68
							{MESSAGE_THEME_IMPORT_HTT}
69 69
							<br style="margin-bottom: 0.5em" />
70 70
							<label for="theme_template">{TXT_THEME_SELECT_HTT}</label><br />
branches/2.8.x/wb/admin/interface/version.php
51 51

  
52 52
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)
53 53
if(!defined('VERSION')) define('VERSION', '2.8.3');
54
if(!defined('REVISION')) define('REVISION', '1650');
54
if(!defined('REVISION')) define('REVISION', '1651');
55 55
if(!defined('SP')) define('SP', '');
branches/2.8.x/wb/admin/addons/CopyTheme.php
37 37
		$this->_oDb   = $GLOBALS['database'];
38 38
		$this->_aLang = $GLOBALS['MESSAGE'];
39 39
	// import global Consts
40
		$this->_aGlobals['TablePrefix']     = TABLE_PREFIX;
41
		$this->_aGlobals['AddonTable']      = 'addons';
42
		$this->_aGlobals['SettingsTable']   = 'settings';
40
		$this->_aGlobals['TablePrefix']   = TABLE_PREFIX;
41
		$this->_aGlobals['AddonTable']    = 'addons';
42
		$this->_aGlobals['SettingsTable'] = 'settings';
43 43

  
44
		$this->_aGlobals['Debug']           = (defined('DEBUG') && DEBUG === true);
45
		$this->_aGlobals['IsLinux']         = ((substr(__FILE__, 0, 1)) == '/');
46
		$this->_aGlobals['StringDirMode']   = STRING_DIR_MODE;
47
		$this->_aGlobals['StringFileMode']  = STRING_FILE_MODE;
44
		$this->_aGlobals['Debug']          = (defined('DEBUG') && DEBUG === true);
45
		$this->_aGlobals['IsLinux']        = ((substr(__FILE__, 0, 1)) == '/');
46
		$this->_aGlobals['DirMode']       = octdec(STRING_DIR_MODE);
47
		$this->_aGlobals['FileMode']      = octdec(STRING_FILE_MODE);
48 48
	}
49 49
/**
50 50
 * start copy current theme into a new theme
......
153 153
			}
154 154
			natsort($aFileList);
155 155
		}catch(Exeption $e) {
156
			$msg  = 'CopyTheme::_copyTree => '.$this->_aLang['GENERIC_FAILED_COMPARE'];
157
			$msg .= '<br />'.$e->getMessage();
156
			$msg  = $this->_aLang['GENERIC_FAILED_COMPARE'];
157
			if($this->_aGlobals['Debug']) {
158
				$msg .= '<br />'.__CLASS__.'::'.__METHOD__. '<br />'.$e->getMessage();
159
			}
158 160
			$this->_setError($msg);
159 161
			$bRetval = false;
160 162
		}
......
181 183
			$sNewDir = $this->_sThemesBasePath.'/'.$this->_sNewThemeDir.$sDir;
182 184
			if(!file_exists($sNewDir) &&  mkdir($sNewDir, 0777, true)) {
183 185
				if($this->_aGlobals['IsLinux']) {
184
					if(!chmod($sNewDir, $this->_aGlobals['StringDirMode'])) {
185
						$sMsg = 'CopyTheme::createDirs::chmod('.$sNewDir.') >> '
186
								.$this->_aLang['GENERIC_FAILED_COMPARE'];
186
					if(!chmod($sNewDir, $this->_aGlobals['DirMode'])) {
187
						$sMsg = $this->_aLang['UPLOAD_ERR_CANT_WRITE'].' ['.$sNewDir.']';
188
						if($this->_aGlobals['Debug']) {
189
							$sMsg .= '<br />'.__CLASS__.'::'.__METHOD__.'::'
190
								 . 'chmod(\''.$sNewDir.$_sThemePath.$sFile.'\', '
191
								 . decoct($this->_aGlobals['DirMode']).')';
192
						}
187 193
						$this->_setError($sMsg);
188 194
						$bRetval = false;
189 195
						break;
190 196
					}
191 197
				}
192 198
			}else {
193
				$sMsg = 'CopyTheme::createDirs::mkdir('.$sNewDir.') >> '
194
						.$this->_aLang['GENERIC_FAILED_COMPARE'];
199
				$sMsg = $this->_aLang['GENERIC_FAILED_COMPARE'].' ['.$sFile.']';
200
				if($this->_aGlobals['Debug']) {
201
					$sMsg .= '<br />'.__CLASS__.'::'.__METHOD__.'::'
202
						 . 'mkdir(\''.$sNewDir.'\', 0777, true)';
203
				}
195 204
				$this->_setError($sMsg);
196 205
				$bRetval = false;
197 206
				break;
......
211 220
		foreach($aFileList as $sFile) {
212 221
			if(copy($sSourceDir.$sFile, $sDestinationDir.$sFile)) {
213 222
				if($this->_aGlobals['IsLinux']) {
214
					if(!chmod($sDestinationDir.$sFile, $this->_aGlobals['StringFileMode'])) {
215
						$sMsg = 'CopyTheme::copyFiles::chmod('.$sDestinationDir.$sFile.') >> '
216
								.$this->_aLang['GENERIC_FAILED_COMPARE'];
223
					if(!chmod($sDestinationDir.$sFile, $this->_aGlobals['FileMode'])) {
224
						$sMsg = $this->_aLang['GENERIC_FAILED_COMPARE'].' ['.$sFile.']';
225
						if($this->_aGlobals['Debug']) {
226
							$sMsg .= '<br />'.__CLASS__.'::'.__METHOD__.'::'
227
								  . 'chmod(\''.$sDestinationDir.$sFile.'\', '
228
								  .decoct($this->_aGlobals['FileMode']).', true)';
229
						}
217 230
						$this->_setError($sMsg);
218 231
						$bRetval = false;
219 232
						break;
220 233
					}
221 234
				}
222 235
			}else {
223
				$sMsg = 'CopyTheme::copyFiles::copy('.$sDestinationDir.$sFile.') >> '
224
						.$this->_aLang['GENERIC_FAILED_COMPARE'];
236
				$sMsg = $this->_aLang['GENERIC_FAILED_COMPARE'].' ['.$sFile.']';
237
				if($this->_aGlobals['Debug']) {
238
					$sMsg .= '<br />'.__CLASS__.'::'.__METHOD__.'::'
239
						  . 'copy(\''.$sSourceDir.$sFile.'\', '
240
					      . '\''.$sDestinationDir.$sFile.'\')';
241
				}
225 242
				$this->_setError($sMsg);
226 243
				$bRetval = false;
227 244
				break;
......
249 266
		     .     '`author`=\''.mysql_real_escape_string($aVariables['author']).'\', '
250 267
		     .     '`license`=\''.mysql_real_escape_string($aVariables['license']).'\'';
251 268
		if(!$this->_oDb->query($sql)) {
252
			$sMsg = 'CopyTheme::registerNewTheme('.$this->_sNewThemeName.') >> '
253
			        .$this->_aLang['GENERIC_NOT_UPGRADED'];
254
			$sMsg .= (($this->_aGlobals['Debug']) ? '<br />'.$this->_oDb->get_error() : '');
269

  
270
			$sMsg = $this->_aLang['GENERIC_NOT_UPGRADED'].' ['.$this->_sNewThemeDir.'/info.php]';
271
			if($this->_aGlobals['Debug']) {
272
				$sMsg .= '<br />'.__CLASS__.'::'.__METHOD__. '<br />'.$this->_oDb->get_error();
273
			}
255 274
			$this->_setError($sMsg);
256 275
			$bRetval = false;
257 276
		}
......
270 289
		$aVariables['name']        = $this->_sNewThemeName;
271 290
		$aVariables['version']     = '0.0.1';
272 291
		$aVariables['description'] = '(copy): '.$aVariables['description'];
273
		if(file_exists($sThemeInfoFile)) {
292
		if(is_writeable($sThemeInfoFile)) {
274 293
			$sInfoContent = file_get_contents($sThemeInfoFile);
275 294
			foreach($aVariables as $key=>$val) {
276 295
				$sSearch  = '/(\$template_'.$key.'\s*=\s*(["\'])).*?(\2)\s*;/s';
......
284 303
				return true;
285 304
			}
286 305
		}
287
		$this->_setError('CopyTheme::modifyInfoFile('.$this->_sNewThemeDir.'/info.php) >> '
288
		               .$this->_aLang['GENERIC_NOT_UPGRADED']);
306
		$sMsg = $this->_aLang['GENERIC_NOT_UPGRADED'].' ['.$this->_sNewThemeDir.'/info.php]';
307
		if($this->_aGlobals['Debug']) {
308
			$sMsg .= '<br />'.__CLASS__.'::'.__METHOD__.'(\''.$sThemeInfoFile.'\')';
309
		}
310
		$this->_setError($sMsg);
289 311
		return $bRetval;
290 312
	}
291 313
/**
......
329 351
		                         'default_theme',
330 352
		                         $value = $this->_sNewThemeDir))
331 353
		{
332
			$sMsg = 'CopyTheme::activateTheme('.$this->_sNewThemeName.') >> '
333
			        .$this->_aLang['GENERIC_NOT_UPGRADED'];
334
			$sMsg .= (($this->_aGlobals['Debug']) ? '<br />'.$this->_oDb->get_error() : '');
354
			$sMsg = $this->_aLang['GENERIC_NOT_UPGRADED'];
355
			if($this->_aGlobals['Debug']) {
356
				$sMsg .= '<br />'.__CLASS__.'::'.__METHOD__. '<br />'.$this->_oDb->get_error();
357
			}
335 358
			$this->_setError($sMsg);
336 359
			$bRetval = false;
337 360
		}
branches/2.8.x/wb/admin/addons/CopyThemeHtt.php
16 16

  
17 17
	private static $_sSkelPath  = ''; 
18 18
	private static $_sThemePath = '';
19
	private static $_sOs        = '';
19
	private static $_IsLinux    = '';
20 20
	private static $_sFileMode  = '';
21 21
	private static $_aLang      = '';
22
	private static $_bDebug     = false;
22 23
/**
23 24
 * import all needed global constants and variables
24 25
 */
......
27 28
//		self::$_sSkelPath  = ADMIN_PATH.'/themes/templates/';
28 29
		self::$_sSkelPath  = ADMIN_PATH.'/skel/themes/htt/';
29 30
		self::$_sThemePath = THEME_PATH.'/templates/';
30
		self::$_sOs        = OPERATING_SYSTEM;
31
		self::$_sFileMode  = STRING_FILE_MODE;
31
		self::$_IsLinux    = ((substr(__FILE__, 0, 1)) == '/');
32
		self::$_sFileMode  = octdec(STRING_FILE_MODE);
33
		self::$_bDebug      = (defined('DEBUG') && DEBUG === true);
34

  
32 35
		self::$_aLang      = $GLOBALS['MESSAGE'];
33 36
	}
34 37
/**
......
59 62
			if(sizeof($aFileList) > 0 ) {
60 63
				foreach($aFileList as $sFile) {
61 64
					$sFile = basename($sFile);
62
					if(copy(self::$_sSkelPath.$sFile, self::$_sThemePath.$sFile)) {
63
						if(self::$_sOs == 'linux') {
64
							chmod(self::$_sThemePath.$sFile, self::$_sFileMode);
65
					if(is_writable(self::$_sThemePath) &&
66
					   copy(self::$_sSkelPath.$sFile, self::$_sThemePath.$sFile))
67
					{
68
						if(self::$_IsLinux) {
69
							if(!chmod(self::$_sThemePath.$sFile, self::$_sFileMode)) {
70
								$msg = self::$_aLang['UPLOAD_ERR_CANT_WRITE'].' ['.$sFile.']';
71
								if(self::$_bDebug) {
72
									$msg .= __CLASS__.'::'.__METHOD__.'::'
73
									     . 'chmod(\'self::'.$_sThemePath.$sFile.'\', '
74
									     . decoct(self::$_sFileMode).')';
75
								}
76
								$aErrors[] = $msg;
77
							}
65 78
						}
66 79
					}else {
67
						$aErrors[] = self::$_aLang['UPLOAD_ERR_CANT_WRITE'].' ['.$sFile.']';
80
						$msg = self::$_aLang['UPLOAD_ERR_CANT_WRITE'].' ['.$sFile.']';
81
						if(self::$_bDebug) {
82
							$msg .= __CLASS__.'::'.__METHOD__.'::'
83
							     . 'copy(\''.self::$_sSkelPath.$sFile.'\', '
84
							     . '\''.self::$_sThemePath.$sFile.'\')';
85
						}
86
						$aErrors[] = $msg;
68 87
					}
69 88
				}
70 89
			}
branches/2.8.x/wb/admin/addons/index.php
106 106
		 . 'WHERE `directory`=\''.DEFAULT_THEME.'\' AND `function`=\'theme\'';
107 107
	$tmp = $database->get_one($sql);
108 108
	$template->set_var('THEME_DEFAULT_NAME', $tmp);
109
	$template->set_var('THEME_PATH', THEME_PATH);
109
	$template->set_var('CURRENT_THEME', $tmp);
110
	$tmp = str_replace(str_replace('\\', '/', WB_PATH), '', str_replace('\\', '/', THEME_PATH));
111
	$template->set_var('THEME_PATH', $tmp);
110 112
// end copy current theme
111 113
// start template import
112 114
	include(dirname(__FILE__).'/CopyThemeHtt.php');
branches/2.8.x/wb/framework/functions.php
414 414
	return $retVal;
415 415
}
416 416

  
417
// Function to chmod files and directories
418
function change_mode($name)
417
/**
418
 * Function to chmod files and/or directories
419
 * @param string $sName
420
 * @param int rights in dec-value. 0= use wb-defaults
421
 * @return bool
422
 */
423
function change_mode($sName, $iMode = 0)
419 424
{
420
	if(OPERATING_SYSTEM != 'windows')
421
    {
422
		// Only chmod if os is not windows
423
		if(is_dir($name)) {
424
			$mode = OCTAL_DIR_MODE;
425
		}else {
426
			$mode = OCTAL_FILE_MODE;
425
	$bRetval = true;
426
	if((substr(__FILE__, 0, 1)) == '/')
427
	{ // Only chmod if os is not windows
428
		$bRetval = false;
429
		if(!$iMode) {
430
			$iMode = (is_file($sName) ? octdec(STRING_FILE_MODE) : octdec(STRING_DIR_MODE));
427 431
		}
428
		if(file_exists($name)) {
429
			$umask = umask(0);
430
			chmod($name, $mode);
431
			umask($umask);
432
			return true;
433
		}else {
434
			return false;
432
		if(is_writable($sName)) {
433
			$bRetval = chmod($sName, $iMode);
435 434
		}
436
	}else {
437
		return true;
438 435
	}
436
	return $bRetval;
439 437
}
440 438

  
441 439
// Function to figure out if a parent exists

Also available in: Unified diff