Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php class ReadTest extends PHPUnit_Framework_TestCase { private $testdata = "Lorem i..

Decoded Output download

<?php

class ReadTest extends PHPUnit_Framework_TestCase
{
	private $testdata =
		"Lorem ipsum dolor sit amet, consectetur adipisicing elit,
		sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
";

	// The URI of the test file seen through Samba:
	private $testuri;

	// The "real" file on the filesystem:
	private $realfile;

	public function
	setup()
	{
		$this->testuri = 'smb://'.SMB_HOST.'/'.SMB_SHARE.'/readtest.txt';
		$this->realfile = SMB_LOCAL.'/readtest.txt';

		file_put_contents($this->realfile, $this->testdata);
	}

	public function
	tearDown()
	{
		@unlink($this->realfile);
	}

	public function
	testReadSuccess()
	{
		$state = smbclient_state_new();
		smbclient_state_init($state, null, SMB_USER, SMB_PASS);
		$file = smbclient_open($state, $this->testuri, 'r');
		$this->assertTrue(is_resource($file));

		for ($data = ''; $tmp = smbclient_read($state, $file, 42) ; $data .= $tmp) {
			$this->assertTrue(\strlen($tmp) > 0 && \strlen($tmp) <= 42);
		}
		$this->assertEmpty($tmp);
		$this->assertEquals($this->testdata, $data);
	}
}
 ?>

Did this file decode correctly?

Original Code

<?php

class ReadTest extends PHPUnit_Framework_TestCase
{
	private $testdata =
		"Lorem ipsum dolor sit amet, consectetur adipisicing elit,
		sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n";

	// The URI of the test file seen through Samba:
	private $testuri;

	// The "real" file on the filesystem:
	private $realfile;

	public function
	setup()
	{
		$this->testuri = 'smb://'.SMB_HOST.'/'.SMB_SHARE.'/readtest.txt';
		$this->realfile = SMB_LOCAL.'/readtest.txt';

		file_put_contents($this->realfile, $this->testdata);
	}

	public function
	tearDown()
	{
		@unlink($this->realfile);
	}

	public function
	testReadSuccess()
	{
		$state = smbclient_state_new();
		smbclient_state_init($state, null, SMB_USER, SMB_PASS);
		$file = smbclient_open($state, $this->testuri, 'r');
		$this->assertTrue(is_resource($file));

		for ($data = ''; $tmp = smbclient_read($state, $file, 42) ; $data .= $tmp) {
			$this->assertTrue(\strlen($tmp) > 0 && \strlen($tmp) <= 42);
		}
		$this->assertEmpty($tmp);
		$this->assertEquals($this->testdata, $data);
	}
}

Function Calls

None

Variables

None

Stats

MD5 51c6cf2d4eb6622d098781e3ea8ab6fb
Eval Count 0
Decode Time 118 ms