Forráskód Böngészése

Some little improvements in litefm to avoid PHP warnings.

DieFeM 8 éve
szülő
commit
a36c2d99ae

+ 4 - 2
modules/litefm/fm_read.php

@@ -63,7 +63,9 @@ function exec_ogp_module()
 	//Logic to open the file we're editing
 	$remote = new OGPRemoteLibrary($home_cfg['agent_ip'], $home_cfg['agent_port'], $home_cfg['encryption_key'], $home_cfg['timeout']);
 	$data = "";
-	$file_info =  $remote->remote_readfile($home_cfg['home_path']."/".$_SESSION['fm_cwd_'.$home_id],$data);
+	$rel_path = isset($_SESSION['fm_cwd_'.$home_id]) ? $_SESSION['fm_cwd_'.$home_id]:'';
+	$filepath = clean_path($home_cfg['home_path']."/".$rel_path);
+	$file_info =  $remote->remote_readfile($filepath ,$data);
 	if ( $file_info === 0 )
 	{
 		print_failure(get_lang("not_found"));
@@ -92,7 +94,7 @@ function exec_ogp_module()
     editor.setTheme("ace/theme/tomorrow");
     (function () {
         var modelist = ace.require("ace/ext/modelist");
-        var filePath = "<?=$_SESSION['fm_cwd_'.$home_id]?>";
+        var filePath = "<?=$rel_path?>";
         var mode = modelist.getModeForPath(filePath).mode;
         console.log(mode);
         editor.session.setMode(mode);

+ 1 - 0
modules/litefm/functions.php

@@ -2,6 +2,7 @@
 function return_bytes($val) {
 	$val = trim($val);
 	$last = strtolower($val[strlen($val)-1]);
+	$val = str_replace($val[strlen($val)-1], '', $val);
 	switch($last) {
 		// El modificador 'G' está disponble desde PHP 5.1.0
 		case 'g':

+ 1 - 1
modules/litefm/litefm.php

@@ -79,7 +79,7 @@ function litefm_check($home_id)
 					$_SESSION['fm_cwd_'.$home_id] = @$_SESSION['fm_cwd_'.$home_id] . "/" . $path;
 					$_SESSION['fm_cwd_'.$home_id] = clean_path($_SESSION['fm_cwd_'.$home_id]);
 				}else{
-					if(!endsWith($_SESSION['fm_cwd_'.$home_id], $path)){
+					if((isset($_SESSION['fm_cwd_'.$home_id]) and !endsWith($_SESSION['fm_cwd_'.$home_id], $path)) or !isset($_SESSION['fm_cwd_'.$home_id])){
 						$_SESSION['fm_cwd_'.$home_id] = @$_SESSION['fm_cwd_'.$home_id] . "/" . $path;
 						$_SESSION['fm_cwd_'.$home_id] = clean_path($_SESSION['fm_cwd_'.$home_id]);
 					}