Codiad-Terminal icon indicating copy to clipboard operation
Codiad-Terminal copied to clipboard

Working directory was this plugin's one when made a project whit absolute path.

Open HiroKws opened this issue 10 years ago • 1 comments

Hi,

I'll report a bug.

I made a new project with specified absolute path.

Then I started this plugin, and checked pwd. It showed this plugin's directory, instead of project root directory.

I read term.php. In the beginning of Terminal class, tried to set home by this code :

define('ROOT',WORKSPACE . '/' . $_SESSION['project']);

But when I set absolute path project, ROOT is not correct path, so path wouldn't set.

So, maybe you will change class constructor code. Like this :

            if(!isset($_SESSION['dir']) || empty($_SESSION['dir'])){
                if(substr($_SESSION['project'],0,1) == '/'){
                    $this->directory = $_SESSION['project'];
                } else {
                    $this->directory = rtrim(WORKSPACE, '/').'/'.$_SESSION['project'];
                }
                $this->ChangeDirectory();
            }else{
                $this->directory = $_SESSION['dir'];
            }
            $this->ChangeDirectory();

Sorry, I don't have time to make pull request.

ML, Hiro

HiroKws avatar Jul 05 '14 19:07 HiroKws

I know this is a VERY old issue, however, I'm trying to get this to work and no matter what I put in that DEFINE line, it always takes me back to /plugins/Codiad-Terminal-master/emulator

I tried replacing @HiroKws 's code, but it doesn't take.

Anyone else?

these are my changes to term.php:

	//////////////////////////////////////////////////////////////////
	// Globals
	//////////////////////////////////////////////////////////////////
	define('ROOT',WORKSPACE.'/cygdrive/c/inetpub/wwwroot/Codiad/workspace'.$_SESSION['project']);
	define('BLOCKED','ssh,telnet');
	//define(' ','ssh,telnet');
	//////////////////////////////////////////////////////////////////
	// Terminal Class
	//////////////////////////////////////////////////////////////////
	class Terminal{
		////////////////////////////////////////////////////
		// Properties
		////////////////////////////////////////////////////
		public $command='';
		public $output='';
		public $directory='';
		// Holder for commands fired by system
		public $command_exec='';
		////////////////////////////////////////////////////
		// Constructor
		////////////////////////////////////////////////////
		
		public function __construct(){
			if(!isset($_SESSION['dir']) || empty($_SESSION['dir'])){
				if(substr($_SESSION['project'],0,1)=='/'){
					$this->directory=$_SESSION['project'];
				}
				else{
					$this->directory=rtrim(WORKSPACE,'/').'/'.$_SESSION['project'];
				}
				$this->ChangeDirectory();
			}
			else{
				$this->directory=$_SESSION['dir'];
			}
			$this->ChangeDirectory();
		}

seanvree avatar Aug 10 '17 14:08 seanvree