[git] presentations.git branch master updated. 4fc0e0f

From: Date: Wed, 22 Feb 2012 08:52:44 +0000
Subject: [git] presentations.git branch master updated. 4fc0e0f
Groups: php.pres 
Request: Send a blank email to pres+get-1774@lists.php.net to get a copy of this message
The branch, master on presentations.git has been updated via 4fc0e0fc6befa301aabbba9a39f090e0104fca1d (commit) from 8d17b9143548572625d0e1ff5214b926b560a24e (commit) http://git.php.net/?p=presentations.git;a=log;h=4fc0e0fc6befa301aabbba9a39f090e0104fca1d;hp=8d17b9143548572625d0e1ff5214b926b560a24e Summary of changes: slides/intro/api_yql3.xml | 32 ++++++++++++++++++++++++ slides/intro/{api_flickr2.xml => api_yql4.xml} | 24 +++++++++-------- slides/intro/hash_coll.png | Bin 0 -> 7384 bytes slides/intro/hash_normal.png | Bin 0 -> 7883 bytes slides/intro/hashdos1.xml | 8 ++++++ slides/intro/hashdos2.xml | 28 +++++++++++++++++++++ slides/intro/hashdos3.xml | 10 +++++++ slides/intro/yql.php | 4 +++ 8 files changed, 95 insertions(+), 11 deletions(-) create mode 100644 slides/intro/api_yql3.xml copy slides/intro/{api_flickr2.xml => api_yql4.xml} (77%) create mode 100644 slides/intro/hash_coll.png create mode 100644 slides/intro/hash_normal.png create mode 100644 slides/intro/hashdos1.xml create mode 100644 slides/intro/hashdos2.xml create mode 100644 slides/intro/hashdos3.xml -- Log ---------------------------------------- commit 4fc0e0fc6befa301aabbba9a39f090e0104fca1d Author: Rasmus Lerdorf <rasmus@php.net> Date: Wed Feb 22 00:44:07 2012 -0800 Rewrote the Flickr image search slides to use YQL diff --git a/slides/intro/api_yql3.xml b/slides/intro/api_yql3.xml new file mode 100644 index 0000000..f934a93 --- /dev/null +++ b/slides/intro/api_yql3.xml @@ -0,0 +1,32 @@ +<slide title="Flickr"> +<break lines="1"/> + +<example result="0" hide="0" fontsize="1.4em"><![CDATA[<?php +include 'yql.php'; +$q = "SELECT * FROM flickr.photos.search(100) WHERE tags='$loc' + AND sort='interestingness-desc' AND api_key='$api_key'"; +foreach(yql($q)->results->photo as $p) + echo '<img src="'.furl($p,'m').'">';]]></example> + +<break lines="1"/> + +<example result="1" hide="1" fontsize="1.4em"><![CDATA[<?php +include 'presentations/slides/intro/yql.php'; +if(!isset($_POST['loc'])) $loc = ':-:location:-:'; +else $loc = $_POST['loc']; +$q = <<<EOQ +select * from flickr.photos.search(100) where tags="$loc" + and sort="interestingness-desc" + and api_key="{$secrets['api_key']}" +EOQ; +$x = yql($q); +foreach($x->results->photo as $p) { + echo '<img src="'.furl($p,'m').'" title="'. + htmlspecialchars($p['title'], ENT_QUOTES, 'utf-8').'"/>'; +} +?> +<form action="<?php echo htmlspecialchars($PHP_SELF)?>" method="POST"> +Location: <input type=text name=loc size=60> +</form>]]></example> + +</slide> diff --git a/slides/intro/api_yql4.xml b/slides/intro/api_yql4.xml new file mode 100644 index 0000000..b1804ca --- /dev/null +++ b/slides/intro/api_yql4.xml @@ -0,0 +1,93 @@ +<slide title="" body_style="background: #dce4e4; font-family: Georgia, Times, serif; overflow: hidden;"> + +<example hide="1" result="1" outputbackground="#dce4e4" fontsize="1.4em"><![CDATA[ +<style> +#pile { + width: 800px; + height: 600px; + margin: 10px auto; + padding: 20px; + position: relative; +} +#pile div { + background: #fff; + position: absolute; + overflow: hidden; + opacity: 0.9; + -webkit-transition: all 1500ms linear; + + -webkit-border-radius: 15px; + -moz-border-radius: 15px; + border-radius: 15px; + + -webkit-box-shadow: -3px -3px 30px #666; + -moz-box-shadow: -3px -3px 30px #666; + box-shadow: -3px -3px 30px #666; +} +#pile img { + -webkit-mask-box-image: url(/images/background.svg); + -webkit-mask-repeat: none; +} +<?php for($i=0; $i<50; $i++): + $rot = rand(-30,30); + $top = rand(-20,475); + $left = rand(-100,720); + $z = rand(1,15); + echo <<<EOB +#pile #img{$i} { + -webkit-transform: rotate({$rot}deg); + -moz-transform: rotate({$rot}deg); + top: {$top}px; + left: {$left}px; + z-index: {$z}; +} +#pile div#img{$i}:hover { + -webkit-transform: rotate(0deg); + -moz-transform: rotate(0deg); + z-index: 999; + opacity: 1; +} + +EOB; +endfor; ?> +</style> +<?php +if(!isset($_REQUEST['loc'])) $loc = ':-:location:-:'; +else $loc = htmlspecialchars($_REQUEST['loc'], ENT_QUOTES, "UTF-8"); +?> +<form style="width:100%; text-align:center;" action="<?php echo htmlspecialchars($PHP_SELF)?>" method="POST"> +<input type=text name=loc autocomplete="off" style="display: inline-block; text-align: center; background:transparent; border:0; font-size:36px;" value="<?php echo $loc?>" size=20 maxlength=60> +</form> +<div id="pile"> +<?php +include 'presentations/slides/intro/yql.php'; +$q = <<<EOQ +select * from flickr.photos.search(100) where tags="$loc" + and sort="interestingness-desc" + and api_key="{$secrets['api_key']}" +EOQ; +$i=0; +$x = yql($q); +foreach($x->results->photo as $p) { + if($i++ > 50) break; + $url = furl($p, 'm'); + $rot = rand(-30,30); + $style = "-webkit-transform: rotate({$rot}deg); -moz-transform: rotate({$rot}deg);"; + $top = rand(50,500); + $left = rand(-50,710); + $style .= "top: {$top}px; left: {$left}px;"; + $z = rand(1,15); + $style .= "z-index: {$z};"; + $t = htmlspecialchars($p['title'], ENT_QUOTES, 'utf-8'); +echo <<<EOI + <div id="img{$i}"> + <img src="{$url}" title="$t" style="display:none" onload="this.style.display='block'" /> + </div> + +EOI; +} +?> +</div> +]]></example> + +</slide> diff --git a/slides/intro/hash_coll.png b/slides/intro/hash_coll.png new file mode 100644 index 0000000..3de8a8d Binary files /dev/null and b/slides/intro/hash_coll.png differ diff --git a/slides/intro/hash_normal.png b/slides/intro/hash_normal.png new file mode 100644 index 0000000..3567d95 Binary files /dev/null and b/slides/intro/hash_normal.png differ diff --git a/slides/intro/hashdos1.xml b/slides/intro/hashdos1.xml new file mode 100644 index 0000000..1b1d4eb --- /dev/null +++ b/slides/intro/hashdos1.xml @@ -0,0 +1,8 @@ +<slide title="HashDOS"> + +<blurb fontsize="4em">What's a HashDOS?</blurb> +<blurb>A hash table with a typical distribution pattern</blurb> +<break lines="1" /> +<image filename="hash_normal.png" align="left" marginleft="20em" clear="left"/> + +</slide> diff --git a/slides/intro/hashdos2.xml b/slides/intro/hashdos2.xml new file mode 100644 index 0000000..cd96636 --- /dev/null +++ b/slides/intro/hashdos2.xml @@ -0,0 +1,28 @@ +<slide title="HashDOS"> + +<blurb fontsize="4em">Creating Hash Collisions</blurb> + +<example fontsize="2em" result='0' title=""><![CDATA[ +POST http://example.com/ HTTP/1.0 + +1024=&2048=&3072=&4096=&5120=&6144=&7168=&8192= +&9216=&10240=&11264=&12288=&13312=&14336=&15360= +&16384=&17408=&18432=&19456=&20480=&21504=&22528= +&23552=&24576=&25600=&26624=&27648=&28672=&29696= +&30720=&31744=&32768=&33792=&34816=&35840=&36864= +&37888=&38912=&39936=&40960=&41984=&43008=&44032= +&45056=&46080=&47104=&48128=&49152=&50176=&51200= +&52224=&53248=&54272=&55296=&56320=&57344=&58368= +&59392=&60416=&61440=&62464=&63488=&64512=&65536= +&66560=&67584=&68608=&69632=&70656=&71680=&72704= +&73728=&74752=&75776=&76800=&77824=&78848=&79872= +&80896=&81920=&82944=&83968=&84992=&86016=&87040= +&88064=&89088=&90112=&91136=&92160=&93184=&94208= +&95232=&96256=&97280=&98304=&99328=&100352=&101376= +... +]]></example> + +<image filename="hash_coll.png" align="left" marginleft="6em" clear="left"/> + +<break lines="1"/> +</slide> diff --git a/slides/intro/hashdos3.xml b/slides/intro/hashdos3.xml new file mode 100644 index 0000000..eb20b93 --- /dev/null +++ b/slides/intro/hashdos3.xml @@ -0,0 +1,10 @@ +<slide title="HashDOS"> + +<blurb fontsize="4em">Prevention</blurb> +<blurb>Randomized hashing, but there are complications</blurb> +<blurb>For now, limit the damage</blurb> +<break lines="1" /> + +<blurb>In PHP 5.3.10 and higher we have:</blurb> +<example fontsize="2em" result='0' title=""><![CDATA[max_input_vars=1000]]></example> +</slide> diff --git a/slides/intro/yql.php b/slides/intro/yql.php index 9bacb9b..02a4256 100644 --- a/slides/intro/yql.php +++ b/slides/intro/yql.php @@ -21,3 +21,7 @@ function yql($q, $fmt='xml') { $x = simplexml_load_file(cache($yql.urlencode($q)."&format=$fmt&env=".urlencode($env))); return $x; } + +function furl($p, $size='s', $ext='jpg') { + return "http://farm{$p['farm']}.static.flickr.com/{$p['server']}/{$p['id']}_{$p['secret']}_{$size}.{$ext}"; +} Thank you for your contribution.

« previous php.pres (#1774) next »