summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2009-10-13 14:01:26 +0000
committerOlivier Blin <oblin@mandriva.com>2009-10-13 14:01:26 +0000
commit412a9c9d6a09f407d3d8afce8f268761bda830f3 (patch)
tree91fd85e78941e89e1cb93dabb452b5b0863ff4ff
parentd76afd78de4da1607adcc3cb15729ab16557b704 (diff)
downloaddrakiso-412a9c9d6a09f407d3d8afce8f268761bda830f3.tar
drakiso-412a9c9d6a09f407d3d8afce8f268761bda830f3.tar.gz
drakiso-412a9c9d6a09f407d3d8afce8f268761bda830f3.tar.bz2
drakiso-412a9c9d6a09f407d3d8afce8f268761bda830f3.tar.xz
drakiso-412a9c9d6a09f407d3d8afce8f268761bda830f3.zip
pass live and opts to build_iso_image
-rwxr-xr-xdraklive4
1 files changed, 3 insertions, 1 deletions
diff --git a/draklive b/draklive
index e4d6133..a160e05 100755
--- a/draklive
+++ b/draklive
@@ -626,6 +626,7 @@ sub create_cdrom_master {
mkdir_p(dirname($dest));
}
build_iso_image(
+ $live, $opts,
$dest,
$live->get_builddir . $live->{prefix}{build}{boot} . '/syslinux',
$live->get_builddir . $live->{prefix}{build}{boot} . get_syslinux_path($live->{media}, $opts),
@@ -647,7 +648,7 @@ sub create_cdrom_master {
}
sub build_iso_image {
- my ($dest, $o_isolinux_path, $isolinux_cfg, $label, @opts) = @_;
+ my ($live, $opts, $dest, $boot_dir, $o_isolinux_path, $isolinux_cfg, $label, @opts) = @_;
my $progress = MDV::Draklive::Progress->new(100, time());
my $in_progress;
@@ -1288,6 +1289,7 @@ sub create_cdrom_replicator {
my $dest = get_disk_replicator_path($live);
$dest =~ s/.img$/.iso/;
build_iso_image(
+ $live, $opts,
$dest,
$live->get_builddir . $live->{prefix}{build}{boot} . '/syslinux',
$syslinux_cfg,
a id='n180' href='#n180'>180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/

namespace phpbb\captcha;

/**
* Main non-gd captcha class
* @ignore
*/
class non_gd
{
	var $filtered_pngs;
	var $width = 320;
	var $height = 50;

	/**
	* Define filtered pngs on init
	*/
	function __construct()
	{
		// If we can we will generate a single filtered png, we avoid nastiness via emulation of some Zlib stuff
		$this->define_filtered_pngs();
	}

	/**
	* Create the image containing $code with a seed of $seed
	*/
	function execute($code, $seed)
	{
		$img_height = $this->height - 10;
		$img_width = 0;

		mt_srand($seed);

		$char_widths = $hold_chars = array();
		$code_len = strlen($code);

		for ($i = 0; $i < $code_len; $i++)
		{
			$char = $code[$i];

			$width = mt_rand(0, 4);
			$raw_width = $this->filtered_pngs[$char]['width'];
			$char_widths[$i] = $width;
			$img_width += $raw_width - $width;

			// Split the char into chunks of $raw_width + 1 length
			if (empty($hold_chars[$char]))
			{
				$hold_chars[$char] = str_split(base64_decode($this->filtered_pngs[$char]['data']), $raw_width + 1);
			}
		}

		$offset_x = mt_rand(0, $this->width - $img_width);
		$offset_y = mt_rand(0, $this->height - $img_height);

		$image = '';
		for ($i = 0; $i < $this->height; $i++)
		{
			$image .= chr(0);

			if ($i > $offset_y && $i < $offset_y + $img_height)
			{
				for ($j = 0; $j < $offset_x; $j++)
				{
					$image .= chr(mt_rand(140, 255));
				}

				for ($j = 0; $j < $code_len; $j++)
				{
					$image .= $this->randomise(substr($hold_chars[$code{$j}][$i - $offset_y - 1], 1), $char_widths[$j]);
				}

				for ($j = $offset_x + $img_width; $j < $this->width; $j++)
				{
					$image .= chr(mt_rand(140, 255));
				}
			}
			else
			{
				for ($j = 0; $j < $this->width; $j++)
				{
					$image .= chr(mt_rand(140, 255));
				}
			}
		}
		unset($hold_chars);

		$image = $this->create_png($image, $this->width, $this->height);

		// Output image
		header('Content-Type: image/png');
		header('Cache-control: no-cache, no-store');
		echo $image;
		exit;
	}

	/**
	* This is designed to randomise the pixels of the image data within
	* certain limits so as to keep it readable. It also varies the image
	* width a little
	*/
	function randomise($scanline, $width)
	{
		$new_line = '';

		$end = strlen($scanline) - ceil($width/2);
		for ($i = (int) floor($width / 2); $i < $end; $i++)
		{
			$pixel = ord($scanline{$i});

			if ($pixel < 190)
			{
				$new_line .= chr(mt_rand(0, 205));
			}
			else if ($pixel > 190)
			{
				$new_line .= chr(mt_rand(145, 255));
			}
			else
			{
				$new_line .= $scanline{$i};
			}
		}

		return $new_line;
	}

	/**
	* This creates a chunk of the given type, with the given data
	* of the given length adding the relevant crc
	*/
	function png_chunk($length, $type, $data)
	{
		$raw = $type . $data;

		return pack('N', $length) . $raw . pack('N', crc32($raw));
	}

	/**
	* Creates greyscale 8bit png - The PNG spec can be found at
	* http://www.libpng.org/pub/png/spec/PNG-Contents.html we use
	* png because it's a fully recognised open standard and supported
	* by practically all modern browsers and OSs
	*/
	function create_png($raw_image, $width, $height)
	{
		// SIG
		$image = pack('C8', 137, 80, 78, 71, 13, 10, 26, 10);

		// IHDR
		$raw = pack('N2', $width, $height);
		$raw .= pack('C5', 8, 0, 0, 0, 0);
		$image .= $this->png_chunk(13, 'IHDR', $raw);

		// IDAT
		if (@extension_loaded('zlib'))
		{
			$raw_image = gzcompress($raw_image);
			$length = strlen($raw_image);
		}
		else
		{
			// The total length of this image, uncompressed, is just a calculation of pixels
			$length = ($width + 1) * $height;

			// Adler-32 hash generation
			// Note: The hash is _backwards_ so we must reverse it

			if (@extension_loaded('hash'))
			{
				$adler_hash = strrev(hash('adler32', $raw_image, true));
			}
			else if (@extension_loaded('mhash'))
			{
				$adler_hash = strrev(mhash(MHASH_ADLER32, $raw_image));
			}
			else
			{
				// Optimized Adler-32 loop ported from the GNU Classpath project
				$temp_length = $length;
				$s1 = 1;
				$s2 = $index = 0;

				while ($temp_length > 0)
				{
					// We can defer the modulo operation:
					// s1 maximally grows from 65521 to 65521 + 255 * 3800
					// s2 maximally grows by 3800 * median(s1) = 2090079800 < 2^31
					$substract_value = ($temp_length < 3800) ? $temp_length : 3800;
					$temp_length -= $substract_value;

					while (--$substract_value >= 0)
					{
						$s1 += ord($raw_image[$index]);
						$s2 += $s1;

						$index++;
					}

					$s1 %= 65521;
					$s2 %= 65521;
				}
				$adler_hash = pack('N', ($s2 << 16) | $s1);
			}

			// This is the same thing as gzcompress($raw_image, 0) but does not need zlib
			$raw_image = pack('C3v2', 0x78, 0x01, 0x01, $length, ~$length) . $raw_image . $adler_hash;

			// The Zlib header + Adler hash make us add on 11
			$length += 11;
		}

		// IDAT
		$image .= $this->png_chunk($length, 'IDAT', $raw_image);

		// IEND
		$image .= $this->png_chunk(0, 'IEND', '');

		return $image;
	}

	/**
	* png image data
	* Each 'data' element is base64_encoded uncompressed IDAT
	*/
	function define_filtered_pngs()
	{
		$this->filtered_pngs = array(
			'0' => array(
				'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A///////////////////olFAkBAAAGDyA4P///M31/////////////wD////////////////0dAgAAAAAAAAAAAAEcPipFGHn////////////AP//////////////6DAAAAAAAAAAAAAAAAAALSEAN+T///////////8A//////////////xAAAAAAAAAAAAAAAAAAAAAACPA/////////////wD/////////////oAAAAAAAAAAAAAAAAAAAAAAAev//////////////AP////////////8oAAAAAAAAPNj/zDAAAAAAAABD//////////////8A////////////1AAAAAAAABjw////5BAAAAAAAADo/////////////wD///////////+QAAAAAAAAbP//////QgAAAAAAAKj/////////////AP///////////1wAAAAAAACs/////8AXAAAAAAAAcP////////////8A////////////OAAAAAAAAND////dNwAAAAAAAABI/////////////wD///////////8gAAAAAAAA4P//7koACwAAAAAAACT/////////////AP///////////wgAAAAAAAD///VqAwaPAAAAAAAAEP////////////8A////////////AAAAAAAAAP/8kQYDavUAAAAAAAAA/////////////wD///////////8AAAAAAAAA/6kNAEru/wAAAAAAAAD/////////////AP///////////wAAAAAAAADAIwA33f//AAAAAAAAAP////////////8A////////////FAAAAAAAADYAI8D///8AAAAAAAAQ/////////////wD///////////8kAAAAAAAAAA2p////5AAAAAAAACD/////////////AP///////////0gAAAAAAAAFkfz////UAAAAAAAAQP////////////8A////////////cAAAAAAAAET1/////7AAAAAAAABo/////////////wD///////////+oAAAAAAAAXfX/////sAAAAAAAAGj/////////////AAAAALgAAAAAAAAwAAAAAAAAAAAAAAD////////////oAAAAAAAACOT////oEAAAAAAAAOD/////////////AP////////////8+AAAAAAAAKMz/zDQAAAAAAAA0//////////////8A////////////7jgAAAAAAAAAAAAAAAAAAAAAAKT//////////////wD///////////VqAwIAAAAAAAAAAAAAAAAAAAA8////////////////AP//////////rQcDaVEAAAAAAAAAAAAAAAAAKOj///////////////8A///////////nblnu/IAIAAAAAAAAAAAAAFzw/////////////////wD////////////79////+iITCAAAAAgSITg////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////w==',
				'width' => 40
			),
			'1' => array(
				'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////8BAAAAAAAP//////////////////AP////////////////////////9sAAAAAAAA//////////////////8A////////////////////////pAAAAAAAAAD//////////////////wD//////////////////////6wEAAAAAAAAAP//////////////////AP////////////////////h4AAAAAAAAAAAA//////////////////8A//////////////////ygJAAAAAAAAAAAAAD//////////////////wD//////////////9x8HAAAAAAAAAAAAAAAAP//////////////////AP//////////////AAAAAAAAAAAAAAAAAAAA//////////////////8A//////////////8AAAAAAAAAAAAAAAAAAAD//////////////////wD//////////////wAAAAAAAAR4AAAAAAAAAP//////////////////AP//////////////AAAAAAA4zP8AAAAAAAAA//////////////////8A//////////////8AAAA4sP///wAAAAAAAAD//////////////////wD//////////////yR80P//////AAAAAAAAAP//////////////////AP////////////////////////8AAAAAAAAA//////////////////8A/////////////////////////wAAAAAAAAD//////////////////wD/////////////////////////AAAAAAAAAP//////////////////AP////////////////////////8AAAAAAAAA//////////////////8A/////////////////////////wAAAAAAAAD//////////////////wD/////////////////////////AAAAAAAAAP//////////////////AP////////////////////////8AAAAAAAAA//////////////////8A/////////////////////////wAAAAAAAAD//////////////////wD/////////////////////////AAAAAAAAAP//////////////////AP////////////////////////8AAAAAAAAA//////////////////8A/////////////////////////wAAAAAAAAD//////////////////wD/////////////////////////AAAAAAAAAP//////////////////AP////////////////////////8AAAAAAAAA//////////////////8A/////////////////////////wAAAAAAAAD//////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
				'width' => 40
			),
			'2' => array(
				'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP/////////////////okFAkCAAABCBIfNT///////////////////8A///////////////8hAgAAAAAAAAAAAAAAFTo/////////////////wD//////////////1QAAAAAAAAAAAAAAAAAACjo////////////////AP////////////+MAAAAAAAAAAAAAAAAAAAAADj///////////////8A////////////9BAAAAAAAAAAAAAAAAAAAAAAALD//////////////wD///////////+gAAAAAAAAAHjs+KwMAAAAAAAAVP//////////////AP///////////1gAAAAAAABM/////6QAAAAAAAAU//////////////8A////////////KAAAAAAAALj/////+AAAAAAAAAD//////////////wD///////////+MfGBMOCAI8P/////wAAAAAAAACP//////////////AP///////////////////////////5wAAAAAAAAw//////////////8A///////////////////////////oFAAAAAAAAHz//////////////wD/////////////////////////6CgAAAAAAAAE3P//////////////AP///////////////////////9ggAAAAAAAAAHT///////////////8A//////////////////////+0DAAAAAAAAAA8+P///////////////wD/////////////////////gAAAAAAAAAAAKOj/////////////////AP//////////////////9FAAAAAAAAAAADzw//////////////////8A/////////////////+g4AAAAAAAAAABk/P///////////////////wD////////////////oKAAAAAAAAAAMqP//////////////////////AP//////////////6CgAAAAAAAAAMNz///////////////////////8A//////////////g4AAAAAAAAAFT0/////////////////////////wD/////////////bAAAAAAAAABU/P//////////////////////////AP///////////8wAAAAAAAAAAAAAAAAAAAAAAAAA//////////////8A////////////SAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////9wAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////AP//////////hAAAAAAAAAAAAAAAAAAAAAAAAAAA//////////////8A//////////9AAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////////wD//////////xAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////////AP////////////////////////////////////////////////////8=',
				'width' => 40
			),
			'3' => array(
				'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD////////////////8sGg0FAAAACA4cLz8////////////////////AP//////////////rBgAAAAAAAAAAAAAACTA//////////////////8A/////////////3QAAAAAAAAAAAAAAAAAAASs/////////////////wD///////////+YAAAAAAAAAAAAAAAAAAAAAAjc////////////////AP//////////6AwAAAAAAAAAAAAAAAAAAAAAAGT///////////////8A//////////94AAAAAAAABJDw/8g4AAAAAAAAHP///////////////wD//////////yAAAAAAAACE/////9gAAAAAAAAA////////////////AP///////////NSwiGQ4FOT//////AAAAAAAABD///////////////8A//////////////////////////+YAAAAAAAAVP///////////////wD//////////////////////P/ggAQAAAAAAATM////////////////AP////////////////////9gAAAAAAAAAAAElP////////////////8A/////////////////////0AAAAAAAAAAHLj//////////////////wD/////////////////////OAAAAAAAAAAwkPj/////////////////AP////////////////////8gAAAAAAAAAAAAINj///////////////8A/////////////////////xAAAAAAAAAAAAAAIPD//////////////wD/////////////////////uOz/4HgEAAAAAAAAhP//////////////AP///////////////////////////3wAAAAAAAAw//////////////8A////////////////////////////6AAAAAAAAAj//////////////wD/////////////////////////////AAAAAAAAAP//////////////AP//////////tJh8YEQoDNz//////+AAAAAAAAAY//////////////8A//////////88AAAAAAAAaP//////dAAAAAAAAEz//////////////wD//////////6QAAAAAAAAAdOD/5HQAAAAAAAAApP//////////////AP///////////CgAAAAAAAAAAAAAAAAAAAAAACD4//////////////8A////////////yAQAAAAAAAAAAAAAAAAAAAAEuP///////////////wD/////////////rAQAAAAAAAAAAAAAAAAABJD/////////////////AP//////////////zDQAAAAAAAAAAAAAACTA//////////////////8A/////////////////8BwOCAAAAAUNGi0/P///////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
				'width' => 40
			),
			'4' => array(
				'data' => 'AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP//////////////////////////nAAAAAAAAAD///////////////8A/////////////////////////8AEAAAAAAAAAP///////////////wD////////////////////////gGAAAAAAAAAAA////////////////AP//////////////////////9DAAAAAAAAAAAAD///////////////8A//////////////////////9UAAAAAAAAAAAAAP///////////////wD/////////////////////hAAAAAAAAAAAAAAA////////////////AP///////////////////7QAAAAAAAAAAAAAAAD///////////////8A///////////////////UDAAAAAAUAAAAAAAAAP///////////////wD/////////////////7CQAAAAABMAAAAAAAAAA////////////////AP////////////////xEAAAAAACU/wAAAAAAAAD///////////////8A////////////////cAAAAAAAZP//AAAAAAAAAP///////////////wD//////////////6AAAAAAADz8//8AAAAAAAAA////////////////AP/////////////IBAAAAAAc6P///wAAAAAAAAD///////////////8A////////////5BgAAAAADMz/////AAAAAAAAAP///////////////wD///////////g0AAAAAACk//////8AAAAAAAAA////////////////AP//////////XAAAAAAAfP///////wAAAAAAAAD///////////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////8A//////////8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///////////wD//////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////////////AP//////////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////////8A////////////////////////////AAAAAAAAAP///////////////wD///////////////////////////8AAAAAAAAA////////////////AP///////////////////////////wAAAAAAAAD///////////////8A////////////////////////////AAAAAAAAAP///////////////wD///////////////////////////8AAAAAAAAA////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8A/////////////////////////////////////////////////////wD/////////////////////////////////////////////////////AP////////////////////////////////////////////////////8=',
				'width' => 40
			),
			'5' => array(