Browse Source

add spanish translation to ajaxfilemanager editor, clean dokeos, fix minor bugs

Juan Carlos Raña 14 years ago
parent
commit
6f5ccc47aa

+ 10 - 2
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_image_editor.php

@@ -150,8 +150,16 @@
 	</fieldset>
 </div>
 <div id="imageArea">
-    <div id="imageContainer"> 
-        <img src="<?php echo "../".$path; ?>" name="<?php echo basename($path); ?>" width="<?php echo $imageInfo['width']; ?>" height="<?php echo $imageInfo['height']; ?>" /><!-- For Dokeos integrating, enter a back directory "../" to avoid introducing main and can not read the image -->
+    <div id="imageContainer">
+    
+	<?php
+	if(Security::remove_XSS($_GET['editor'])!='stand_alone'){
+	
+		$path='../'.$path;//<!-- For Chamilo integrating, enter a back directory "../" to avoid introducing main and can not read the image -->
+	}
+	?>
+        <img src="<?php echo $path; ?>" name="<?php echo basename($path); ?>" width="<?php echo $imageInfo['width']; ?>" height="<?php echo $imageInfo['height']; ?>" />
+        
     </div>
     <div id="resizeMe">
     	<div id="resizeSE"></div>

+ 166 - 166
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajax_text_editor.php

@@ -1,166 +1,166 @@
-<?php
-		/**
-	 * Ajax image editor platform
-	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
-	 * @link www.phpletter.com
-	 * @since 22/May/2007
-	 *
-	 */
-	require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
-	if(CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_EDITABLE)
-	{
-		die(SYS_DISABLED);
-	}	
-		$session->gc();
-		$_GET['path'] = empty($_GET['path'])?CONFIG_SYS_ROOT_PATH . "ajax_image_editor_demo.jpg":$_GET['path'];
-		if(!empty($_GET['path']) && file_exists($_GET['path']) && is_file($_GET['path']) && isUnderRoot($_GET['path']))
-		{
-				$path = $_GET['path'];
-		}else 
-		{
-			die(TXT_FILE_NOT_FOUND);
-		}
-		if(file_exists(DIR_AJAX_EDIT_AREA . "reg_syntax" . DIRECTORY_SEPARATOR . getFileExt($path) . ".js"))
-		{
-			$syntax = getFileExt($path);			
-		}else 
-		{
-			switch (getFileExt($path))
-			{
-				case 'htm':
-					$syntax = 'html';
-					break;
-				default:
-					$syntax = 'basic';
-			}
-		}
-		if(array_search(getFileExt($path), getValidTextEditorExts())=== false)
-		{
-			die(TXT_DISALLOWED_EXT);	
-		}
-	?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="author" content="Logan Cai" />
-<meta name="website" content="http://www.phpletter.com" />
-<script type="text/javascript" src="jscripts/ajaxtexteditor_c.js"></script>
-<!--<script type="text/javascript" src="jscripts/jquery.js"></script>
-<script type="text/javascript" src="jscripts/form.js"></script>
-<script type="text/javascript" src="jscripts/select.js"></script>
-<script type="text/javascript" src="jscripts/jqModal.js"></script>
-<script type="text/javascript" src="jscripts/ajaxtexteditor.js"></script>
--->
-<script type="text/javascript" src="jscripts/edit_area/edit_area_full.js"></script>
-<script type="text/javascript">
-				var warningExtNotSelected = '<?php echo TXT_EXT_NOT_SELECTED; ?>';
-				var urlGetFolderList = '<?php echo appendQueryString(CONFIG_URL_GET_FOLDER_LIST, makeQueryString(array('path'))); ?>';
-				var warningInvalidName = '<?php echo TXT_SAVE_AS_ERR_NAME_INVALID; ?>';
-				var waringFolderNotSelected = '<?php echo TXT_DEST_FOLDER_NOT_SELECTED; ?>';
-				var currentFolder = '<?php echo dirname($path); ?>';
-				var currentName = '<?php echo basename($path); ?>';
-
-		jQuery(document).ready(
-		function()
-		{
-				editAreaLoader.init({				
-				id: "content"	// id of the textarea to transform		
-				,start_highlight: false	// if start with highlight
-				,allow_resize: "both"
-				,gecko_spellcheck:true
-				,allow_toggle: true
-				,toolbar:"search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, highlight, reset_highlight, |, save, save_as"
-				,save_callback:"save"
-				,save_as_callback:"save_as"
-				,language: "<?php echo (file_exists(DIR_AJAX_EDIT_AREA . 'langs' . DIRECTORY_SEPARATOR .CONFIG_LANG_INDEX . ".js")?CONFIG_LANG_INDEX:'en'); ?>"
-				,syntax: "<?php echo $syntax; ?>"	
-			});				
-				jQuery('#windowSaveAs').jqm();		
-				jQuery('#windowProcessing').jqm({modal:true});				
-		}
-	);		
-
-		
-
-			
-</script>
-
-<link href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/ajaxtexteditor.css" type="text/css" rel="stylesheet" />
-<link href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/jqModal.css" type="text/css" rel="stylesheet" />
-<title>Ajax Text Editor</title>
-</head>
-<body>
-
-<div id="pageBody">
-	<textarea name="content" id="content" style="height:500px; width: 97%;"><?php echo getFileContent($path); ?></textarea>
-</div>
-<div id="windowProcessing" class="jqmWindow" style="display:none">
-	<form name="frmProcessing" id="frmProcessing" method="POST" action="<?php echo appendQueryString(CONFIG_URL_SAVE_TEXT, makeQueryString(array('path')));?>">
-		<input type="hidden" name="folder" id="folder" value="<?php echo dirname($path); ?>" />
-		<input type="hidden" name="name" id="name" value="<?php echo basename($path); ?>" />	
-		<input type="hidden" name="save_as_request" id="save_as_request" value="0" />
-		<div style="display:none"><textarea name="text" id="text"></textarea></div> 
-	</form> 
-	<a href="#" class="jqmClose" id="windowSaveClose"><?php echo IMG_BTN_CANCEL; ?></a>
-	<p><img src="theme/<?php echo CONFIG_THEME_NAME; ?>/images/loading.gif" /></p>
-</div>
-<div id="windowSaveAs" class="jqmWindow" style="display:none">
-    	<a href="#" class="jqmClose" id="windowSaveClose"><?php echo IMG_BTN_CANCEL; ?></a>
-      <form id="formSaveAs" name="formSaveAs" action="" method="post">
-    	<table class="tableForm" cellpadding="0" cellspacing="0">
-      	<thead>
-        	<tr>
-          	<th colspan="2"><?php echo IMG_LBL_SAVE_AS; ?></th>
-          </tr>
-        </thead>
-        <tbody>
-        	<tr>
-          	<th>
-            	<label><?php echo IMG_LBL_NEW_NAME; ?></label>
-            </th>
-            <td>
-            	<input type="text" id="new_name" class="input" name="new_name" value="" />
-              &nbsp;.&nbsp;<select id="ext" name="ext">
-              <?php
-								foreach(getValidTextEditorExts() as $v)
-								{
-									?>
-									<option value="<?php echo $v; ?>" <?php echo (strtolower($v) == strtolower(getFileExt($path))?'selected':''); ?>><?php echo $v; ?></option>
-									<?php
-								}
-							?>
-              </select>
-            </td>
-          </tr>
-          <tr>
-          	<th>
-            	<label><?php echo IMG_LBL_SAVE_TO; ?></label>
-            </th>
-            <td>
-            	<select class="input" name="save_to" id="save_to">
-              	
-              </select>
-            </td>
-          </tr>
-          <tr>
-          	<th>&nbsp;
-            </th>
-            <td>
-            <span class="comments">*</span>
-            <?php echo IMG_NEW_NAME_COMMENTS; ?>
-            </td>
-          </tr>
-        </tbody>
-        <tfoot>
-        	<tr>
-        	<th>&nbsp;</th>
-          <td><input type="button" class="button" value="<?php echo IMG_BTN_SAVE_AS; ?>" onclick="return do_save_as();" /></td>
-          </tr>
-        </tfoot>
-      </table>
-      </form>
-    </div>
-
-</body></html>
-
+<?php
+		/**
+	 * Ajax image editor platform
+	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
+	 * @link www.phpletter.com
+	 * @since 22/May/2007
+	 *
+	 */
+	require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "inc" . DIRECTORY_SEPARATOR . "config.php");
+	if(CONFIG_SYS_VIEW_ONLY || !CONFIG_OPTIONS_EDITABLE)
+	{
+		die(SYS_DISABLED);
+	}	
+		//$session->gc(); //disabled for Chamilo
+		$_GET['path'] = empty($_GET['path'])?CONFIG_SYS_ROOT_PATH . "ajax_image_editor_demo.jpg":$_GET['path'];
+		if(!empty($_GET['path']) && file_exists($_GET['path']) && is_file($_GET['path']) && isUnderRoot($_GET['path']))
+		{
+				$path = $_GET['path'];
+		}else 
+		{
+			die(TXT_FILE_NOT_FOUND);
+		}
+		if(file_exists(DIR_AJAX_EDIT_AREA . "reg_syntax" . DIRECTORY_SEPARATOR . getFileExt($path) . ".js"))
+		{
+			$syntax = getFileExt($path);			
+		}else 
+		{
+			switch (getFileExt($path))
+			{
+				case 'htm':
+					$syntax = 'html';
+					break;
+				default:
+					$syntax = 'basic';
+			}
+		}
+		if(array_search(getFileExt($path), getValidTextEditorExts())=== false)
+		{
+			die(TXT_DISALLOWED_EXT);	
+		}
+	?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta name="author" content="Logan Cai" />
+<meta name="website" content="http://www.phpletter.com" />
+<script type="text/javascript" src="jscripts/ajaxtexteditor_c.js"></script>
+<!--<script type="text/javascript" src="jscripts/jquery.js"></script>
+<script type="text/javascript" src="jscripts/form.js"></script>
+<script type="text/javascript" src="jscripts/select.js"></script>
+<script type="text/javascript" src="jscripts/jqModal.js"></script>
+<script type="text/javascript" src="jscripts/ajaxtexteditor.js"></script>
+-->
+<script type="text/javascript" src="jscripts/edit_area/edit_area_full.js"></script>
+<script type="text/javascript">
+				var warningExtNotSelected = '<?php echo TXT_EXT_NOT_SELECTED; ?>';
+				var urlGetFolderList = '<?php echo appendQueryString(CONFIG_URL_GET_FOLDER_LIST, makeQueryString(array('path'))); ?>';
+				var warningInvalidName = '<?php echo TXT_SAVE_AS_ERR_NAME_INVALID; ?>';
+				var waringFolderNotSelected = '<?php echo TXT_DEST_FOLDER_NOT_SELECTED; ?>';
+				var currentFolder = '<?php echo dirname($path); ?>';
+				var currentName = '<?php echo basename($path); ?>';
+
+		jQuery(document).ready(
+		function()
+		{
+				editAreaLoader.init({				
+				id: "content"	// id of the textarea to transform		
+				,start_highlight: false	// if start with highlight
+				,allow_resize: "both"
+				,gecko_spellcheck:true
+				,allow_toggle: true
+				,toolbar:"search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, highlight, reset_highlight, |, save, save_as"
+				,save_callback:"save"
+				,save_as_callback:"save_as"
+				,language: "<?php echo (file_exists(DIR_AJAX_EDIT_AREA . 'langs' . DIRECTORY_SEPARATOR .CONFIG_LANG_INDEX . ".js")?CONFIG_LANG_INDEX:'en'); ?>"
+				,syntax: "<?php echo $syntax; ?>"	
+			});				
+				jQuery('#windowSaveAs').jqm();		
+				jQuery('#windowProcessing').jqm({modal:true});				
+		}
+	);		
+
+		
+
+			
+</script>
+
+<link href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/ajaxtexteditor.css" type="text/css" rel="stylesheet" />
+<link href="theme/<?php echo CONFIG_THEME_NAME; ?>/css/jqModal.css" type="text/css" rel="stylesheet" />
+<title>Ajax Text Editor</title>
+</head>
+<body>
+
+<div id="pageBody">
+	<textarea name="content" id="content" style="height:500px; width: 97%;"><?php echo getFileContent($path); ?></textarea>
+</div>
+<div id="windowProcessing" class="jqmWindow" style="display:none">
+	<form name="frmProcessing" id="frmProcessing" method="POST" action="<?php echo appendQueryString(CONFIG_URL_SAVE_TEXT, makeQueryString(array('path')));?>">
+		<input type="hidden" name="folder" id="folder" value="<?php echo dirname($path); ?>" />
+		<input type="hidden" name="name" id="name" value="<?php echo basename($path); ?>" />	
+		<input type="hidden" name="save_as_request" id="save_as_request" value="0" />
+		<div style="display:none"><textarea name="text" id="text"></textarea></div> 
+	</form> 
+	<a href="#" class="jqmClose" id="windowSaveClose"><?php echo IMG_BTN_CANCEL; ?></a>
+	<p><img src="theme/<?php echo CONFIG_THEME_NAME; ?>/images/loading.gif" /></p>
+</div>
+<div id="windowSaveAs" class="jqmWindow" style="display:none">
+    	<a href="#" class="jqmClose" id="windowSaveClose"><?php echo IMG_BTN_CANCEL; ?></a>
+      <form id="formSaveAs" name="formSaveAs" action="" method="post">
+    	<table class="tableForm" cellpadding="0" cellspacing="0">
+      	<thead>
+        	<tr>
+          	<th colspan="2"><?php echo IMG_LBL_SAVE_AS; ?></th>
+          </tr>
+        </thead>
+        <tbody>
+        	<tr>
+          	<th>
+            	<label><?php echo IMG_LBL_NEW_NAME; ?></label>
+            </th>
+            <td>
+            	<input type="text" id="new_name" class="input" name="new_name" value="" />
+              &nbsp;.&nbsp;<select id="ext" name="ext">
+              <?php
+								foreach(getValidTextEditorExts() as $v)
+								{
+									?>
+									<option value="<?php echo $v; ?>" <?php echo (strtolower($v) == strtolower(getFileExt($path))?'selected':''); ?>><?php echo $v; ?></option>
+									<?php
+								}
+							?>
+              </select>
+            </td>
+          </tr>
+          <tr>
+          	<th>
+            	<label><?php echo IMG_LBL_SAVE_TO; ?></label>
+            </th>
+            <td>
+            	<select class="input" name="save_to" id="save_to">
+              	
+              </select>
+            </td>
+          </tr>
+          <tr>
+          	<th>&nbsp;
+            </th>
+            <td>
+            <span class="comments">*</span>
+            <?php echo IMG_NEW_NAME_COMMENTS; ?>
+            </td>
+          </tr>
+        </tbody>
+        <tfoot>
+        	<tr>
+        	<th>&nbsp;</th>
+          <td><input type="button" class="button" value="<?php echo IMG_BTN_SAVE_AS; ?>" onclick="return do_save_as();" /></td>
+          </tr>
+        </tfoot>
+      </table>
+      </form>
+    </div>
+
+</body></html>
+

+ 2 - 2
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.file.php

@@ -34,13 +34,13 @@
 					$this->fileInfo['ctime'] = $this->fileStat[10];	
 					$this->fileInfo['mtime'] = $this->fileStat[9];
 					$this->fileInfo['path'] = $path;
-					$this->fileInfo['name'] = str_replace('_',' ',basename($path));	//for Dokeos. Prevent long file name
+					$this->fileInfo['name'] = str_replace('_',' ',basename($path));	//for Chamilo. Prevent long file name
 					$this->fileInfo['is_writable'] = $this->isWritable();
 					$this->fileInfo['is_readable'] = $this->isReadable();
 				}elseif(is_dir($this->filePath))
 				{
 					$this->fileStat = @stat($path);
-					$this->fileInfo['name'] = str_replace('_',' ',basename($path));	//for Dokeos. Prevent long file name
+					$this->fileInfo['name'] = str_replace('_',' ',basename($path));	//for Chamilo. Prevent long file name
 					$this->fileInfo['path'] = $path;
 					$this->fileInfo['atime'] = $this->fileStat[8];
 					$this->fileInfo['ctime'] = $this->fileStat[10];	

+ 1 - 1
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.search.php

@@ -162,7 +162,7 @@
 							}
 						}elseif(is_dir($path) && $this->searchkeywords['recursive'])
 						{
-							$this->doSearch($path); // For Dokeos this line replaces $this->Search($baseFolderPath); to run the search recursively from the root directory
+							$this->doSearch($path); // For Chamilo this line replaces $this->Search($baseFolderPath); to run the search recursively from the root directory
 						}
 					}
 				}

+ 231 - 228
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.session.php

@@ -1,229 +1,232 @@
-<?php
-
-	/**
-	 * this class provide a function like session handling engine
-	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
-	 * @link www.phpletter.com
-	 * @since 22/May/2007
-	 *
-	 */
-
-require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "class.file.php");
-class Session 
-{
-    var $lifeTime;
-    var $fp = null;
-    var $dir = null;
-    var $mTime = null;
-    var $sessionDir = null;
-    var $sessionFile = null;
-    var $ext = '.txt';
-    var $gcCounter = 5; //call gc to delete expired session each ten request
-		var $gcCounterFileName = 'gc_counter.ajax.php';
-		var $gcCounterFile = null;
-		var $gcLogFileName = 'gc_log.ajax.php';
-		var $gcLogFile = null;
-		var $debug = true; //turn it on when you want to see gc log
-		
-		
-    /**
-     * constructor
-     *
-     */
-    function __construct()
-    {
-    	//check if the session folder read and writable
-    		$dir = new file();
-	        if(!file_exists(CONFIG_SYS_DIR_SESSION_PATH))
-	        {
-	           if(!$dir->mkdir(CONFIG_SYS_DIR_SESSION_PATH))
-	           {
-	              die('Unable to create session folder.');
-	           }
-	        }
-    		if(!$dir->isReadable(CONFIG_SYS_DIR_SESSION_PATH))
-    		{
-    			die('Permission denied: ' . CONFIG_SYS_DIR_SESSION_PATH . " is not readable.");
-    		}    		
-    		if(!$dir->isWritable(CONFIG_SYS_DIR_SESSION_PATH))
-    		{
-    			die('Permission denied: ' . CONFIG_SYS_DIR_SESSION_PATH . " is not writable.");
-    		}
-    	$this->dir = backslashToSlash(addTrailingSlash(CONFIG_SYS_DIR_SESSION_PATH));
-        $this->lifeTime = get_cfg_var("session.gc_maxlifetime");  
-        $this->gcCounterFile = $this->dir . $this->gcCounterFileName; 
-        $this->gcLogFile = $this->dir  . $this->gcLogFileName;
-       	$this->sessionDir = backslashToSlash($this->dir.session_id().DIRECTORY_SEPARATOR);
-        $this->init();    	
-    }
-     /**
-     * constructor
-     *
-     */   
-    function Session() 
-    {
-    		$this->__construct();        
-    }
-    /**
-     * session init
-     * @return boolean
-     */
-    function init() 
-    {
-
-        
-        
-    }
-    
-    function gc()
-    {
-     		//init the counter file
-        $fp = @fopen($this->gcCounterFile, 'a+');
-        if($fp)
-        {
-        	$count = intval(fgets($fp, 999999)) + 1;
-        	if($count > $this->gcCounter || rand(0, 23) == date('h'))
-        	{
-        		$this->_gc();
-        		$count = 0;
-        	}
-        	@ftruncate($fp, 0);
-        	if(!@fputs($fp, $count))
-        	{
-        		die(SESSION_COUNTER_FILE_WRITE_FAILED);
-        	}
-        	@fclose($fp);
-        }else 
-        {
-        	die(SESSION_COUNTER_FILE_CREATE_FAILED);
-        }   	
-    }
-
-    /**
-     * garbage collection function
-     *
-     */
-    function _gc() 
-    {
-			//remove expired file from session folder
-	 		$dirHandler = @opendir($this->dir);
-	 		$output = '';
-	 		$output .= "gc start at " . date('d/M/Y H:i:s') . "\n";
-	 		$fo = new file();
-			if($dirHandler)
-			{
-				while(false !== ($file = readdir($dirHandler)))
-				{
-					if($file != '.' && $file != '..' && $file != $this->gcCounterFileName && $file != $this->gcLogFileName && $file != session_id() )
-					{						
-						$path=$this->dir.$file;
-						$output .= $path ;
-						//check if this is a expired session file
-						if(filemtime($path) + $this->lifeTime < time())
-						{							
-							if($fo->delete($path))
-							{
-								$output .= ' Deleted at ' . date('d/M/Y H:i:s');
-							}else 
-							{
-								$output .= " Failed at " . date('d/M/Y H:i:s');
-							}																			
-						}
-						$output .= "\n";
-											
-					}
-				}
-				if($this->debug)
-				{
-					$this->_log($output);
-				}
-				
-				@closedir($dirHandler);
-
-			} 
-			if(CONFIG_SYS_DEMO_ENABLE)
-			{
-				//remove expired files from uploaded folder
-		 		$dirHandler = @opendir(CONFIG_SYS_ROOT_PATH);
-		 		$output = '';
-		 		$output .= "gc start at " . date('d/M/Y H:i:s') . "\n";
-		 		$fo = new file();
-				if($dirHandler)
-				{
-					while(false !== ($file = readdir($dirHandler)))
-					{
-						if($file != '.' && $file != '..')
-						{						
-							$path=CONFIG_SYS_ROOT_PATH.$file;
-							$output .= $path ;
-							//check if this is a expired session file
-							if(filemtime($path) + $this->lifeTime < time())
-							{							
-								if($fo->delete($path))
-								{
-									$output .= ' Deleted at ' . date('d/M/Y H:i:s');
-								}else 
-								{
-									$output .= " Failed at " . date('d/M/Y H:i:s');
-								}																			
-							}
-							$output .= "\n";
-												
-						}
-					}
-					if($this->debug)
-					{
-						$this->_log($output);
-					}
-					
-					@closedir($dirHandler);
-	
-				}					
-			}
-		    
-    }
-    /**
-     * log action taken by the gc
-     *
-     * @param unknown_type $msg
-     */
-    function _log($msg)
-    {
-    	$msg = "<?php die(); ?>\n" . $msg;
-    	$fp = @fopen($this->gcLogFile, 'w+');
-    	if($fp)
-    	{
-    		@ftruncate($fp, 0);
-    		!@fputs($fp, $msg);
-    		@fclose($fp);
-    	}
-    }
-    
-    /**
-     * get the current session directory
-     *
-     * @return string return empty if failed
-     */
-    function getSessionDir()
-    {
-    	if(!file_exists($this->sessionDir) && !is_dir($this->sessionDir))
-    	{
-    		$dir = new file();
-    		if(!$dir->mkdir($this->sessionDir))
-    		{
-    			return '';
-    		}
-    	}else 
-    	{
-	     	if(!@is_dir($this->sessionDir))
-	    	{
-	    		return '';
-	    	}   		
-    	}
-    	return $this->sessionDir;
-    }
-    
-
-    
-}
+<?php
+
+	/**
+	 * this class provide a function like session handling engine
+	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
+	 * @link www.phpletter.com
+	 * @since 22/May/2007
+	 *
+	 */
+
+require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "class.file.php");
+class Session 
+{
+    var $lifeTime;
+    var $fp = null;
+    var $dir = null;
+    var $mTime = null;
+    var $sessionDir = null;
+    var $sessionFile = null;
+    var $ext = '.txt';
+    var $gcCounter = 5; //call gc to delete expired session each ten request
+		var $gcCounterFileName = 'gc_counter.ajax.php';
+		var $gcCounterFile = null;
+		var $gcLogFileName = 'gc_log.ajax.php';
+		var $gcLogFile = null;
+		var $debug = true; //turn it on when you want to see gc log
+		
+		
+    /**
+     * constructor
+     *
+     */
+    function __construct()
+    {
+    	//check if the session folder read and writable
+    		$dir = new file();
+	        if(!file_exists(CONFIG_SYS_DIR_SESSION_PATH))
+	        {
+	           if(!$dir->mkdir(CONFIG_SYS_DIR_SESSION_PATH))
+	           {
+	              die('Unable to create session folder.');
+	           }
+	        }
+    		if(!$dir->isReadable(CONFIG_SYS_DIR_SESSION_PATH))
+    		{
+    			die('Permission denied: ' . CONFIG_SYS_DIR_SESSION_PATH . " is not readable.");
+    		}    		
+    		if(!$dir->isWritable(CONFIG_SYS_DIR_SESSION_PATH))
+    		{
+    			die('Permission denied: ' . CONFIG_SYS_DIR_SESSION_PATH . " is not writable.");
+    		}
+    	$this->dir = backslashToSlash(addTrailingSlash(CONFIG_SYS_DIR_SESSION_PATH));
+        $this->lifeTime = get_cfg_var("session.gc_maxlifetime");  
+        $this->gcCounterFile = $this->dir . $this->gcCounterFileName; 
+        $this->gcLogFile = $this->dir  . $this->gcLogFileName;
+       	$this->sessionDir = backslashToSlash($this->dir.session_id().DIRECTORY_SEPARATOR);
+        $this->init();    	
+    }
+     /**
+     * constructor
+     *
+     */   
+    function Session() 
+    {
+    		$this->__construct();        
+    }
+    /**
+     * session init
+     * @return boolean
+     */
+    function init() 
+    {
+
+        
+        
+    }
+    
+    function gc()
+    {
+     		//init the counter file
+        $fp = @fopen($this->gcCounterFile, 'a+');
+        if($fp)
+        {
+        	$count = intval(fgets($fp, 999999)) + 1;
+        	if($count > $this->gcCounter || rand(0, 23) == date('h'))
+        	{
+        		$this->_gc();
+        		$count = 0;
+        	}
+        	@ftruncate($fp, 0);
+        	if(!@fputs($fp, $count))
+        	{
+        		die(SESSION_COUNTER_FILE_WRITE_FAILED);
+        	}
+        	@fclose($fp);
+        }else 
+        {
+        	die(SESSION_COUNTER_FILE_CREATE_FAILED);
+        }   	
+    }
+
+    /**
+     * garbage collection function
+     *
+     */
+    function _gc() 
+    {
+			//remove expired file from session folder
+	 		$dirHandler = @opendir($this->dir);
+	 		$output = '';
+	 		$output .= "gc start at " . date('d/M/Y H:i:s') . "\n";
+	 		$fo = new file();
+			if($dirHandler)
+			{
+				while(false !== ($file = readdir($dirHandler)))
+				{
+					// This is to preserve the empty index.html and during development - the hidden .svn folder. No need for Chamilo because ajaxfilemanager sessions are disabled
+					//if($file != '.' && $file != '..' && $file != $this->gcCounterFileName && $file != $this->gcLogFileName && $file != session_id() )
+					if($file != '.' && $file != '..' && $file != $this->gcCounterFileName && $file != $this->gcLogFileName && $file != session_id()
+					&& $file != 'index.html' && $file != '.svn')					
+					{						
+						$path=$this->dir.$file;
+						$output .= $path ;
+						//check if this is a expired session file
+						if(filemtime($path) + $this->lifeTime < time())
+						{							
+							if($fo->delete($path))
+							{
+								$output .= ' Deleted at ' . date('d/M/Y H:i:s');
+							}else 
+							{
+								$output .= " Failed at " . date('d/M/Y H:i:s');
+							}																			
+						}
+						$output .= "\n";
+											
+					}
+				}
+				if($this->debug)
+				{
+					$this->_log($output);
+				}
+				
+				@closedir($dirHandler);
+
+			} 
+			if(CONFIG_SYS_DEMO_ENABLE)
+			{
+				//remove expired files from uploaded folder
+		 		$dirHandler = @opendir(CONFIG_SYS_ROOT_PATH);
+		 		$output = '';
+		 		$output .= "gc start at " . date('d/M/Y H:i:s') . "\n";
+		 		$fo = new file();
+				if($dirHandler)
+				{
+					while(false !== ($file = readdir($dirHandler)))
+					{
+						if($file != '.' && $file != '..')
+						{						
+							$path=CONFIG_SYS_ROOT_PATH.$file;
+							$output .= $path ;
+							//check if this is a expired session file
+							if(filemtime($path) + $this->lifeTime < time())
+							{							
+								if($fo->delete($path))
+								{
+									$output .= ' Deleted at ' . date('d/M/Y H:i:s');
+								}else 
+								{
+									$output .= " Failed at " . date('d/M/Y H:i:s');
+								}																			
+							}
+							$output .= "\n";
+												
+						}
+					}
+					if($this->debug)
+					{
+						$this->_log($output);
+					}
+					
+					@closedir($dirHandler);
+	
+				}					
+			}
+		    
+    }
+    /**
+     * log action taken by the gc
+     *
+     * @param unknown_type $msg
+     */
+    function _log($msg)
+    {
+    	$msg = "<?php die(); ?>\n" . $msg;
+    	$fp = @fopen($this->gcLogFile, 'w+');
+    	if($fp)
+    	{
+    		@ftruncate($fp, 0);
+    		!@fputs($fp, $msg);
+    		@fclose($fp);
+    	}
+    }
+    
+    /**
+     * get the current session directory
+     *
+     * @return string return empty if failed
+     */
+    function getSessionDir()
+    {
+    	if(!file_exists($this->sessionDir) && !is_dir($this->sessionDir))
+    	{
+    		$dir = new file();
+    		if(!$dir->mkdir($this->sessionDir))
+    		{
+    			return '';
+    		}
+    	}else 
+    	{
+	     	if(!@is_dir($this->sessionDir))
+	    	{
+	    		return '';
+	    	}   		
+    	}
+    	return $this->sessionDir;
+    }
+    
+
+    
+}
 ?>

+ 1 - 1
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.upload.php

@@ -205,7 +205,7 @@
 		{
 			$this->fileBaseName = $fileBaseName;
 		}
-		$this->fileBaseName=disable_dangerous_file(replace_dangerous_char(str_replace(' ','_',$this->fileBaseName),'strict'));// Juan Carlos Raña replace space by _ because fix long names. See: ajaxfilemanager/inc/class.manager.php. And add cleaning from dokeos replace_dangerous_char() and disable_dangerous_file()
+		$this->fileBaseName=disable_dangerous_file(replace_dangerous_char(str_replace(' ','_',$this->fileBaseName),'strict'));// Juan Carlos Raña replace space by _ because fix long names. See: ajaxfilemanager/inc/class.manager.php. And add cleaning from Chamilo replace_dangerous_char() and disable_dangerous_file()
 		$fileName = $this->fileBaseName . $this->fileExtension;
 		$filePath = $dest . $fileName;
 

+ 23 - 23
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/config.base.php

@@ -6,7 +6,7 @@
 	 * @since 1/August/2007
 	 *
 	 *
-	 * Modify system config setting for Dokeos
+	 * Modify system config setting for Chamilo
 	 * @author Juan Carlos Raña Trabado
 	 * @since 31/December/2008
 	 */
@@ -38,7 +38,7 @@
 	define('CONFIG_SYS_THUMBNAIL_VIEW_ENABLE', true);//REMOVE THE thumbnail view if false
 
 	//User Permissions
-	//Hack by Juan Carlos Raa Trabado
+	//Hack by Juan Carlos Raña Trabado
 	if(empty($_course['path']))
 	{
 		define('CONFIG_OPTIONS_DELETE', true);
@@ -46,20 +46,20 @@
 		define('CONFIG_OPTIONS_COPY', true);
 		define('CONFIG_OPTIONS_NEWFOLDER', true);
 		define('CONFIG_OPTIONS_RENAME', true);
-		define('CONFIG_OPTIONS_UPLOAD', true); //
+		define('CONFIG_OPTIONS_UPLOAD', true);
 		define('CONFIG_OPTIONS_EDITABLE', false); //disable image editor and text editor
 	}
 	else
 	{
 		if(api_is_allowed_to_edit())
 		{
-		//api_is_allowed_to_edit() from Dokeos
+		//api_is_allowed_to_edit() from Chamilo
 			define('CONFIG_OPTIONS_DELETE', true);
 			define('CONFIG_OPTIONS_CUT', false);
 			define('CONFIG_OPTIONS_COPY', false);
 			define('CONFIG_OPTIONS_NEWFOLDER', true);
 			define('CONFIG_OPTIONS_RENAME', false);
-			define('CONFIG_OPTIONS_UPLOAD', true); //
+			define('CONFIG_OPTIONS_UPLOAD', true);
 			define('CONFIG_OPTIONS_EDITABLE', false); //disable image editor and text editor
 
 		}
@@ -70,7 +70,7 @@
 			define('CONFIG_OPTIONS_COPY', false);
 			define('CONFIG_OPTIONS_NEWFOLDER', true);
 			define('CONFIG_OPTIONS_RENAME', false);
-			define('CONFIG_OPTIONS_UPLOAD', true); //
+			define('CONFIG_OPTIONS_UPLOAD', true);
 			define('CONFIG_OPTIONS_EDITABLE', false); //disable image editor and text editor
 		}
 	}
@@ -85,30 +85,30 @@
 			//define('CONFIG_SYS_DEFAULT_PATH', '../uploaded/'); //accept relative path only
 			//define('CONFIG_SYS_ROOT_PATH', '../uploaded/');	//accept relative path only
 
-	/////////////// Integration for Dokeos
+	/////////////// Integration for Chamilo
 
 	if(!empty($_course['path']))
 	{
 		if(!empty($group_properties['directory']))
 		{
-			$PathDokeosAjaxFileManager='../../../../../../../courses/'.$_course['path'].'/document'.$group_properties['directory'].'/';
+			$PathChamiloAjaxFileManager='../../../../../../../courses/'.$_course['path'].'/document'.$group_properties['directory'].'/';
 		}
 		else
 		{
 			if(api_is_allowed_to_edit())
 			{
-				$PathDokeosAjaxFileManager='../../../../../../../courses/'.$_course['path'].'/document/';
+				$PathChamiloAjaxFileManager='../../../../../../../courses/'.$_course['path'].'/document/';
 			}
 			else
 			{
 				$current_session_id = api_get_session_id();
 				if($current_session_id==0)
 				{
-					$PathDokeosAjaxFileManager='../../../../../../../courses/'.$_course['path'].'/document/shared_folder/sf_user_'.api_get_user_id().'/';
+					$PathChamiloAjaxFileManager='../../../../../../../courses/'.$_course['path'].'/document/shared_folder/sf_user_'.api_get_user_id().'/';
 				}
 				else
 				{
-					$PathDokeosAjaxFileManager='../../../../../../../courses/'.$_course['path'].'/document/shared_folder_session_'.$current_session_id.'/sf_user_'.api_get_user_id().'/';
+					$PathChamiloAjaxFileManager='../../../../../../../courses/'.$_course['path'].'/document/shared_folder_session_'.$current_session_id.'/sf_user_'.api_get_user_id().'/';
 				}				
 			}
 		}
@@ -118,20 +118,20 @@
 		if (api_is_platform_admin() && $_SESSION['this_section']=='platform_admin')
 		{
 			//home page portal
-			$PathDokeosAjaxFileManager='../../../../../../../home/default_platform_document/';
+			$PathChamiloAjaxFileManager='../../../../../../../home/default_platform_document/';
 		}
 		else
 		{
 			//my profile
-			$PathDokeosAjaxFileManager='../../../../../../../main/upload/users/'.api_get_user_id().'/my_files/';
+			$PathChamiloAjaxFileManager='../../../../../../../main/upload/users/'.api_get_user_id().'/my_files/';
 		}
 
 	}
 
-	define('CONFIG_SYS_DEFAULT_PATH', $PathDokeosAjaxFileManager);
-	define('CONFIG_SYS_ROOT_PATH', $PathDokeosAjaxFileManager);
+	define('CONFIG_SYS_DEFAULT_PATH', $PathChamiloAjaxFileManager);
+	define('CONFIG_SYS_ROOT_PATH', $PathChamiloAjaxFileManager);
 
-	////////////// end dokeos
+	////////////// end chamilo
 
 	define('CONFIG_SYS_FOLDER_SHOWN_ON_TOP', true); //show your folders on the top of list if true or order by name
 
@@ -154,14 +154,14 @@
 	define('CONFIG_SYS_DELETE_RECURSIVE', 1); //delete all contents within a specific folder if set to be 1
 
 	//UPLOAD OPTIONS CONFIG
-	define('CONFIG_UPLOAD_MAXSIZE', 50000 * 1024 ); //by bytes For Dokeos upgrade from 50 to 50000 (50MB)
+	define('CONFIG_UPLOAD_MAXSIZE', 50000 * 1024 ); //by bytes For Chamilo upgrade from 50 to 50000 (50MB)
 
-	define('CONFIG_EDITABLE_VALID_EXTS', 'txt,htm,html'); //make you include all these extension in CONFIG_UPLOAD_VALID_EXTS if you want all valid. For Dokeos exclude original xml, js and css
+	define('CONFIG_EDITABLE_VALID_EXTS', 'txt,htm,html'); //make you include all these extension in CONFIG_UPLOAD_VALID_EXTS if you want all valid. For Chamilo exclude original xml, js and css
 
 	define('CONFIG_OVERWRITTEN', false); //overwirte when processing paste
-	define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,jpeg,png,bmp,tif,psd,zip,sit,rar,gz,tar,htm,html,mov,mpg,avi,asf,mpeg,wmv,aif,aiff,wav,mp3,swf, flv, mp4, aac, ppt,rtf,doc, pdf,xls,txt,flv,odt,ods,odp,odg,odc,odf,odb,odi,pps,docx,pptx,xlsx,accdb,xml, mid');//For Dokeos updated
-	define("CONFIG_VIEWABLE_VALID_EXTS", 'gif,bmp,txt,jpg,jpeg,png,tif,html,htm,mp3,wav,wmv,wma,rm,rmvb,mov,swf,flv,mp4,aac,avi,mpg,mpeg,asf,mid');//For Dokeos updated
-	define('CONFIG_UPLOAD_INVALID_EXTS', 'php,php3,php4,php5,php6,phps,phtml,asp,aspx,jsp,cfm,cfc,pl,jar,sh,cgi,js,exe,com,bat,pif,scr,msi,ws,wsc,wsf,vb,vbe,vbs,reg,dll'); //For Dokeos added.
+	define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,jpeg,png,bmp,tif,psd,zip,sit,rar,gz,tar,htm,html,mov,mpg,avi,asf,mpeg,wmv,aif,aiff,wav,mp3,swf, flv, mp4, aac, ppt,rtf,doc, pdf,xls,txt,flv,odt,ods,odp,odg,odc,odf,odb,odi,pps,docx,pptx,xlsx,accdb,xml, mid');//For Chamilo updated
+	define("CONFIG_VIEWABLE_VALID_EXTS", 'gif,bmp,txt,jpg,jpeg,png,tif,html,htm,mp3,wav,wmv,wma,rm,rmvb,mov,swf,flv,mp4,aac,avi,mpg,mpeg,asf,mid');//For Chamilo updated
+	define('CONFIG_UPLOAD_INVALID_EXTS', 'php,php3,php4,php5,php6,phps,phtml,asp,aspx,jsp,cfm,cfc,pl,jar,sh,cgi,js,exe,com,bat,pif,scr,msi,ws,wsc,wsf,vb,vbe,vbs,reg,dll'); //For Chamilo added.
 	//Preview
 	define('CONFIG_IMG_THUMBNAIL_MAX_X', 100);
 	define('CONFIG_IMG_THUMBNAIL_MAX_Y', 100);
@@ -200,10 +200,10 @@
 					fckeditor
 			*/
 	//CONFIG_EDITOR_NAME replaced CONFIG_THEME_MODE since @version 0.8
-	define('CONFIG_EDITOR_NAME', (CONFIG_QUERY_STRING_ENABLE && !empty($_GET['editor'])?secureFileName($_GET['editor']):'fckeditor')); // run mode fckeditor (Dokeos editor)
+	define('CONFIG_EDITOR_NAME', (CONFIG_QUERY_STRING_ENABLE && !empty($_GET['editor'])?secureFileName($_GET['editor']):'fckeditor')); // run mode fckeditor (Chamilo editor)
 	define('CONFIG_THEME_NAME', (CONFIG_QUERY_STRING_ENABLE && !empty($_GET['theme'])?secureFileName($_GET['theme']):'default'));  //change the theme to your custom theme rather than default
 	define('CONFIG_DEFAULT_VIEW', (CONFIG_SYS_THUMBNAIL_VIEW_ENABLE?'thumbnail':'detail')); //thumbnail or detail
-	define('CONFIG_DEFAULT_PAGINATION_LIMIT', 10000); //change 10 by 10000 while pagination is deactivated on Dokeos
+	define('CONFIG_DEFAULT_PAGINATION_LIMIT', 10000); //change 10 by 10000 while pagination is deactivated on Chamilo
 	define('CONFIG_LOAD_DOC_LATTER', false); //all documents will be loaded up after the template has been loaded to the client
 
 

+ 1 - 1
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/config.php

@@ -6,7 +6,7 @@
 	 * @version 1.0
 	 * @since 22/April/2007
 	 *
-	 * Modifications of system config setting for Dokeos
+	 * Modifications of system config setting for Chamilo
 	 * @author Juan Carlos Raña Trabado
 	 * @since 31/December/2008
 	 */

+ 6 - 6
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/function.base.php

@@ -1230,11 +1230,11 @@ function getRootPath() {
 */
 function hideFolderName($folderName)
 {
-	//hidden files and folders deleted by Dokeos. Hidde folders css, hotpotatoes, chat
-	$deleted_by_dokeos='_DELETED_';
-	$css_folder_dokeos='css';
-	$hotpotatoes_folder_dokeos='HotPotatoes_files';
-	$chat_files_dokeos='chat_files';
+	//hidden files and folders deleted by Chamilo. Hidde folders css, hotpotatoes, chat
+	$deleted_by_chamilo='_DELETED_';
+	$css_folder_chamilo='css';
+	$hotpotatoes_folder_chamilo='HotPotatoes_files';
+	$chat_files_chamilo='chat_files';
 	$thumbs_folder='.thumbs';
 
 	//hidden directory of the group if the user is not a member of the group
@@ -1251,7 +1251,7 @@ function hideFolderName($folderName)
 		}
 	}
 
-	if(!ereg($deleted_by_dokeos, $folderName) && !ereg($css_folder_dokeos, $folderName) && !ereg($hotpotatoes_folder_dokeos, $folderName) && !ereg($chat_files_dokeos, $folderName) && !ereg($thumbs_folder, $folderName) && $show_doc_group==true)
+	if(!ereg($deleted_by_chamilo, $folderName) && !ereg($css_folder_chamilo, $folderName) && !ereg($hotpotatoes_folder_chamilo, $folderName) && !ereg($chat_files_chamilo, $folderName) && !ereg($thumbs_folder, $folderName) && $show_doc_group==true)
 	{
 		return substr($folderName,strpos($folderName, '-'),strlen($folderName)); //hide the firsts numbers
 	}

+ 46 - 0
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/jscripts/edit_area/langs/es.js

@@ -0,0 +1,46 @@
+editAreaLoader.lang["es"]={
+new_document: "nuevo documento",
+search_button: "buscar y reemplazar",
+search_command: "buscar siguiente / abrir ventana de búsqueda",
+search: "buscar",
+replace: "reemplazar",
+replace_command: "reemplazar / abrir ventana de búsqueda",
+find_next: "buscar siguiente",
+replace_all: "reemplazar todo",
+reg_exp: "expresiones regulares",
+match_case: "Coincidir mayúsculas y minúsculas",
+not_found: "no encontrado.",
+occurrence_replaced: "elementos reemplazados.",
+search_field_empty: "Campo de búsqueda vacío",
+restart_search_at_begin: "Se alcanzó el final del texto. Reiniciar de nuevo.",
+move_popup: "mover la ventana de búsqueda",
+font_size: "--Tamaño de fuente--",
+go_to_line: "ir a la línea",
+go_to_line_prompt: "ir a la línea número:",
+undo: "deshacer",
+redo: "rehacer",
+change_smooth_selection: "habilitar/deshabilitar mejoras de visualzación (visualización más elegante pero más carga para la CPU)",
+highlight: "activar coloreado sintáctico si/no",
+reset_highlight: "reiniciar el coloreado sintáctico (si no hay sincronización con el texto)",
+help: "sobre",
+save: "guardar",
+save_as: "guardar como",
+load: "cargar",
+line_abbr: "Ln",
+char_abbr: "Cr",
+position: "Posición",
+total: "Total",
+close_popup: "cerrar popup",
+shortcuts: "Accesos rápidos",
+add_tab: "añadir tabulación al texto",
+remove_tab: "quitar la tabulación del texto",
+about_notice: "Nota: el coloreado sintáctico es sólo para textos cortos",
+toggle: "Activar el editor",
+accesskey: "Teclas de acceso",
+tab: "Tab",
+shift: "Mayúsc",
+ctrl: "Ctrl",
+esc: "Esc",
+processing: "Procesando...",
+fullscreen: "Pantalla completa"
+};