- Adding the missing slides
@@ -36,6 +36,7 @@
|
||||
|
||||
<!-- Preventing -->
|
||||
<slide>slides/errorhandling/user-input.xml</slide>
|
||||
<slide>slides/errorhandling/user-input2.xml</slide>
|
||||
<slide>slides/errorhandling/check-return-value.xml</slide>
|
||||
|
||||
<!-- Dry theory -->
|
||||
@@ -45,16 +46,19 @@
|
||||
|
||||
<!-- Testing! -->
|
||||
<slide>slides/errorhandling/function-lib.xml</slide>
|
||||
<slide>slides/errorhandling/test-all-paths1.xml</slide>
|
||||
<slide>slides/errorhandling/test-all-paths2.xml</slide>
|
||||
|
||||
<slide>slides/errorhandling/phpunit1.xml</slide>
|
||||
<slide>slides/errorhandling/phpunit2.xml</slide>
|
||||
<slide>slides/errorhandling/phpunit3.xml</slide>
|
||||
<slide>slides/errorhandling/phpunit4.xml</slide>
|
||||
<slide>slides/errorhandling/phpunit5.xml</slide>
|
||||
|
||||
<!-- Still problems? Debug! -->
|
||||
<slide>slides/errorhandling/debug.xml</slide>
|
||||
<slide>slides/errorhandling/xdebug.xml</slide>
|
||||
<slide>slides/errorhandling/xdebug-cb-dump.xml</slide>
|
||||
<slide>slides/errorhandling/xdebug-trace.xml</slide>
|
||||
<slide>slides/errorhandling/xdebug-profile.xml</slide>
|
||||
<slide>slides/errorhandling/xdebug-demo.xml</slide>
|
||||
|
||||
<slide>slides/errorhandling/weaverslave.xml</slide>
|
||||
|
||||
<slide>slides/errorhandling/questions.xml</slide>
|
||||
<slide>slides/errorhandling/resources.xml</slide>
|
||||
|
||||
25
slides/errorhandling/check-return-value.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<slide fontsize="6em">
|
||||
<title>Checking Return Values</title>
|
||||
|
||||
<blurb> </blurb>
|
||||
<blurb>PHP 4:</blurb>
|
||||
<example fontsize="1.2em"><![CDATA[<?php
|
||||
if (@mysql_connect('localhost', 'root', 'ut34FblY:')) {
|
||||
if (@mysql_select_db('game')) {
|
||||
$r = mysql_query('SELECT * FROM news ORDER BY date DESC LIMIT 1');
|
||||
|
||||
...]]></example>
|
||||
|
||||
<blurb> </blurb>
|
||||
<blurb>PHP 5:</blurb>
|
||||
<example fontsize="1.2em"><![CDATA[<?php
|
||||
try {
|
||||
mysql_connect('localhost', 'root', 'ut34FblY:'));
|
||||
mysql_select_db('game');
|
||||
$r = mysql_query('SELECT * FROM news ORDER BY date DESC LIMIT 1');
|
||||
} catch (Exception $e) {
|
||||
/* Do recovery */
|
||||
exit();
|
||||
}]]></example>
|
||||
</slide>
|
||||
BIN
slides/errorhandling/debug.gif
Normal file
|
After Width: | Height: | Size: 25 KiB |
14
slides/errorhandling/debug.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<slide fontsize="6em" title="Debug">
|
||||
<blurb> </blurb>
|
||||
<blurb> </blurb>
|
||||
<blurb> </blurb>
|
||||
<image align="center" filename="debug.gif" />
|
||||
<list marginleft="4em" effect="slide" fontsize="5em">
|
||||
<bullet>Not perfect code</bullet>
|
||||
<bullet>Time to debug!</bullet>
|
||||
<bullet>"echo" debugging</bullet>
|
||||
<bullet>Time consuming</bullet>
|
||||
</list>
|
||||
|
||||
</slide>
|
||||
BIN
slides/errorhandling/demo.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
slides/errorhandling/error_cb.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
55
slides/errorhandling/function-lib.xml
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<slide fontsize="6em" title="Testing">
|
||||
<image align="right" filename="monkey_typing.png" />
|
||||
|
||||
<example fontsize="0.7em"><![CDATA[<?php
|
||||
function crop_string ($str, $length)
|
||||
{
|
||||
if (strlen($str) > $length - 3) {
|
||||
$lines = split("\n", wordwrap($str, $length - 3));
|
||||
return $lines[0]. "...";
|
||||
} else {
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
?>]]></example>
|
||||
|
||||
<example fontsize="0.7em"><![CDATA[<?php
|
||||
include 'lib.php';
|
||||
|
||||
$tests = array (
|
||||
'crop_string' => array(
|
||||
array('foo...', 'foo', 1),
|
||||
array('foo...', 'foo', 3),
|
||||
array('foo', 'foo', 7),
|
||||
array('', '', 1),
|
||||
array('', '', 7),
|
||||
array('Hello...', 'Hello world', 1),
|
||||
array('Hello...', 'Hello world', 7),
|
||||
array('Hello world', 'Hello world', 17),
|
||||
),
|
||||
);
|
||||
$functions = get_defined_functions();
|
||||
$functions = $functions['user'];
|
||||
|
||||
foreach ($functions as $function) {
|
||||
if (isset($tests[$function])) {
|
||||
$i = 0;
|
||||
|
||||
foreach ($tests[$function] as $test) {
|
||||
$i++;
|
||||
switch (count($test)) {
|
||||
case 2: $res = $function($test[1]); break;
|
||||
case 3: $res = $function($test[1], $test[2]); break;
|
||||
}
|
||||
|
||||
if ($res != $test[0]) {
|
||||
echo "FAILED test $function, $i: Expected '{$test[0]}' got '$res'\n";
|
||||
} else {
|
||||
echo "PASSED test $function, $i\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>]]></example>
|
||||
</slide>
|
||||
BIN
slides/errorhandling/monkey_typing.png
Normal file
|
After Width: | Height: | Size: 64 KiB |
15
slides/errorhandling/phpunit1.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<slide fontsize="6em" title="PHPUnit">
|
||||
<blurb> </blurb>
|
||||
<blurb> </blurb>
|
||||
<blurb> </blurb>
|
||||
<blurb> </blurb>
|
||||
<image align="right" filename="bug.gif" />
|
||||
<list effect="slide" fontsize="5em">
|
||||
<bullet>PEAR Class</bullet>
|
||||
<bullet>%pear install PHPUnit%</bullet>
|
||||
<bullet>Easy testing of class (methods)</bullet>
|
||||
<bullet>Automated</bullet>
|
||||
</list>
|
||||
|
||||
</slide>
|
||||
46
slides/errorhandling/phpunit2.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<slide fontsize="6em" title="Running Testsuite">
|
||||
|
||||
<example fontsize="0.8em"><![CDATA[<?php
|
||||
class CropString {
|
||||
function cropString($str, $length)
|
||||
{
|
||||
if (strlen($str) > $length - 3) {
|
||||
$lines = split("\n", wordwrap($str, $length - 3));
|
||||
$this->result = $lines[0]. "...";
|
||||
} else {
|
||||
$this->result = $str;
|
||||
}
|
||||
}
|
||||
?>]]></example>
|
||||
|
||||
<example fontsize="0.8em"><![CDATA[<?php
|
||||
require_once 'crop_string.class.php';
|
||||
require_once 'PHPUnit.php';
|
||||
|
||||
class CropStringTest extends PHPUnit_TestCase {
|
||||
function CropStringTest($name) {
|
||||
PHPUnit_TestCase::PHPUnit_TestCase($name);
|
||||
}
|
||||
|
||||
function emptyTest() {
|
||||
$cstring = new CropString('', 1);
|
||||
$this->assertTrue($cstring->result == '');
|
||||
}
|
||||
function fooTest() {
|
||||
$cstring = new CropString('foo', 1);
|
||||
$this->assertTrue($cstring->result == 'foo...');
|
||||
}
|
||||
function helloWorldTest() {
|
||||
$cstring = new CropString('Hello world', 1);
|
||||
$this->assertTrue($cstring->result == 'Hello...');
|
||||
}
|
||||
}
|
||||
$suite = new PHPUnit_TestSuite();
|
||||
$suite->addTest(new CropStringTest('emptyTest'));
|
||||
$suite->addTest(new CropStringTest('fooTest'));
|
||||
$suite->addTest(new CropStringTest('helloWorldTest'));
|
||||
$result = PHPUnit::run($suite);
|
||||
echo $result->toString();
|
||||
?>]]></example>
|
||||
</slide>
|
||||
BIN
slides/errorhandling/profile.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
slides/errorhandling/shot_4.png
Normal file
|
After Width: | Height: | Size: 148 KiB |
BIN
slides/errorhandling/trace.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
16
slides/errorhandling/user-input.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<slide fontsize="6em">
|
||||
<title>User Input</title>
|
||||
|
||||
<blurb> </blurb>
|
||||
<blurb> </blurb>
|
||||
<blurb> </blurb>
|
||||
<blurb> </blurb>
|
||||
<blurb> </blurb>
|
||||
|
||||
<list effect="slide" fontsize="5em">
|
||||
<bullet>Users are evil!</bullet>
|
||||
<bullet>register_globals == evil</bullet>
|
||||
<bullet>$_GET, $_POST, $_COOKIE, $_REQUEST, $_ENV, $_SERVER</bullet>
|
||||
</list>
|
||||
</slide>
|
||||
16
slides/errorhandling/user-input2.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<slide fontsize="6em">
|
||||
<title>User Input (2)</title>
|
||||
|
||||
<blurb> </blurb>
|
||||
<blurb> </blurb>
|
||||
<blurb> </blurb>
|
||||
<blurb> </blurb>
|
||||
|
||||
<list effect="slide" fontsize="5em">
|
||||
<bullet>Cross Site Scripting</bullet>
|
||||
<bullet>SQL injection</bullet>
|
||||
<bullet>String cut attacks</bullet>
|
||||
<bullet>include() and eval()</bullet>
|
||||
</list>
|
||||
</slide>
|
||||
BIN
slides/errorhandling/vardump.png
Normal file
|
After Width: | Height: | Size: 659 B |
6
slides/errorhandling/weaverslave.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<slide fontsize="6em">
|
||||
<title>Weaverslave</title>
|
||||
|
||||
<image align="center" filename="shot_4.png" />
|
||||
</slide>
|
||||
14
slides/errorhandling/xdebug-cb-dump.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<slide fontsize="6em">
|
||||
<title>Modified PHP functions</title>
|
||||
|
||||
<blurb> </blurb>
|
||||
<blurb>Modified error handler: </blurb>
|
||||
<image align="center" filename="error_cb.png"/>
|
||||
|
||||
<blurb> </blurb>
|
||||
<blurb> </blurb>
|
||||
<blurb> </blurb>
|
||||
<blurb>Modified var_dump() function:</blurb>
|
||||
<image align="center" filename="vardump.png"/>
|
||||
</slide>
|
||||
8
slides/errorhandling/xdebug-demo.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<slide fontsize="6em">
|
||||
<title>Demo</title>
|
||||
|
||||
<blurb> </blurb>
|
||||
<image align="center" filename="demo.png"/>
|
||||
|
||||
</slide>
|
||||
13
slides/errorhandling/xdebug-profile.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<slide fontsize="6em">
|
||||
<title>Profiling</title>
|
||||
|
||||
<image align="center" filename="profile.png"/>
|
||||
|
||||
<blurb> </blurb>
|
||||
<list effect="slide" fontsize="4.5em">
|
||||
<bullet>xdebug_start_profile()</bullet>
|
||||
<bullet>xdebug_dump_function_profile(mode)</bullet>
|
||||
<bullet marginleft="2em">8 profiling modes</bullet>
|
||||
</list>
|
||||
</slide>
|
||||
14
slides/errorhandling/xdebug-trace.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<slide fontsize="6em">
|
||||
<title>Tracing</title>
|
||||
|
||||
<blurb> </blurb>
|
||||
<image align="center" filename="trace.png"/>
|
||||
|
||||
<blurb> </blurb>
|
||||
<blurb> </blurb>
|
||||
<list effect="slide" fontsize="5em">
|
||||
<bullet>xdebug_start_trace()</bullet>
|
||||
<bullet>xdebug_dump_function_trace()</bullet>
|
||||
</list>
|
||||
</slide>
|
||||
16
slides/errorhandling/xdebug.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<slide fontsize="6em" title="Xdebug">
|
||||
<blurb> </blurb>
|
||||
<blurb> </blurb>
|
||||
<blurb> </blurb>
|
||||
<blurb> </blurb>
|
||||
<list effect="slide" fontsize="4.5em">
|
||||
<bullet>Helps finding bugs</bullet>
|
||||
<bullet>Zend extension</bullet>
|
||||
<bullet type="none" marginleft="2em">zend_extension=/path/to/xdebug.so</bullet>
|
||||
<bullet type="none" marginleft="2em">zend_extension_ts=C:/path/to/xdebug.dll</bullet>
|
||||
<bullet>Hooks into error handler</bullet>
|
||||
<bullet type="none" marginleft="2em">and function exection</bullet>
|
||||
</list>
|
||||
|
||||
</slide>
|
||||