diff options
| -rw-r--r-- | arrfuncs.php | 41 | ||||
| -rw-r--r-- | class_ex.php | 72 | ||||
| -rw-r--r-- | cms/content.php | 40 | ||||
| -rw-r--r-- | cms/index.php | 40 | ||||
| -rw-r--r-- | cms/staff.php | 40 | ||||
| -rw-r--r-- | control.php | 56 | ||||
| -rw-r--r-- | databases.php | 40 | ||||
| -rw-r--r-- | datatypes.php | 70 | ||||
| -rw-r--r-- | dtime_format.php | 21 | ||||
| -rw-r--r-- | dtime_unix.php | 23 | ||||
| -rw-r--r-- | dynaval.php | 23 | ||||
| -rw-r--r-- | encoding.php | 26 | ||||
| -rw-r--r-- | example.html | 30 | ||||
| -rw-r--r-- | fetch.php | 36 | ||||
| -rw-r--r-- | files/code.jpg | bin | 0 -> 132090 bytes | |||
| -rw-r--r-- | files/dave at garage.jpg | bin | 0 -> 122260 bytes | |||
| -rw-r--r-- | files/decap.jpg | bin | 0 -> 96050 bytes | |||
| -rw-r--r-- | files/pc.jpg | bin | 0 -> 137228 bytes | |||
| -rw-r--r-- | files/soldering.jpg | bin | 0 -> 215880 bytes | |||
| -rw-r--r-- | forms.php | 51 | ||||
| -rw-r--r-- | functions.php | 56 | ||||
| -rw-r--r-- | headers.php | 24 | ||||
| -rw-r--r-- | hello.php | 19 | ||||
| -rw-r--r-- | included_func.php | 8 | ||||
| -rw-r--r-- | includes.php | 19 | ||||
| -rw-r--r-- | insert.php | 75 | ||||
| -rw-r--r-- | process.php | 53 | ||||
| -rw-r--r-- | reference.php | 29 | ||||
| -rw-r--r-- | request.php | 22 | ||||
| -rw-r--r-- | scope.php | 50 | ||||
| -rw-r--r-- | server_req_vars.php | 32 | ||||
| -rw-r--r-- | session.php | 31 | ||||
| -rw-r--r-- | wmlcards.html | 156 | 
33 files changed, 1183 insertions, 0 deletions
diff --git a/arrfuncs.php b/arrfuncs.php new file mode 100644 index 0000000..3595b99 --- /dev/null +++ b/arrfuncs.php @@ -0,0 +1,41 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 +<html xmlns="http://www.w3.org/1999/xhtml">
 +<head>
 +<title>Hacker's Corner</title>
 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 +</head>
 +<body>
 +<h2>Beyond The Basics?</h2>
 +<p>
 +shift and unshift chops/prepends the beginning of the array<br />
 +<?php
 +    $arr = array("bro", "bro bro", "brotato", "foo");
 +    print_r($arr);
 +    echo "<br /><br />\n";
 +
 +    /* shift a value from an array */
 +    $a = array_shift($arr);
 +    echo $a . "<br /><br />\n";
 +
 +    /* unshift an element, this func returns the element count */
 +    $c = array_unshift($arr, $a);
 +    print_r($arr);
 +    echo "<br /><br />\n";
 +?>
 +
 +pop and push<br /> 
 +<?php
 +    /* pop a value from an array */
 +    $a = array_pop($arr);
 +    echo $a . "<br /><br />\n";
 +
 +    /* push back an element, this func returns the element count */
 +    $c = array_push($arr, "foo");
 +    $c = array_push($arr, "bar");
 +    print_r($arr);
 +?>
 +</p>
 +</body>
 +</html>
 +
 diff --git a/class_ex.php b/class_ex.php new file mode 100644 index 0000000..710a28b --- /dev/null +++ b/class_ex.php @@ -0,0 +1,72 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 +<html xmlns="http://www.w3.org/1999/xhtml">
 +<head>
 +<title>Hacker's Corner</title>
 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 +</head>
 +<body>
 +<h2>Beyond The Basics?</h2>
 +
 +<?php
 +
 +class Person
 +{
 +    public $name; /* good convention to put public explicitly */
 +    public $lname; /* but public in front of 'var' errors out yo */
 +    /* should I just avoid var modifier */
 +    /* var public means public public, wrong! */
 +
 +    static $id = 0;
 +
 +    function __construct($name, $lname)
 +    {
 +        $this->name = $name;
 +        $this->lname = $lname;
 +        Person::$id++;
 +    }
 +
 +    function __clone()
 +    {
 +        $this->increment(); /* we're cloning, creating another person, so increase count */
 +    }
 +
 +    function fullname()
 +    {
 +        return $this->name . " " . $this->lname;
 +    }
 +
 +    static function increment()
 +    {
 +        self::$id++; /* another way to mean Person:: */
 +    }
 +}
 +
 +class Employee extends Person
 +{
 +    static function oneup()
 +    {
 +        parent::increment(); /* refer to parent's stuff */
 +    }
 +};
 +
 +$person = new Person("Kyle", "Broflovski");
 +echo $person->fullname() . "<br />\n";
 +
 +$me = clone $person;
 +$me->lname = "K";
 +echo $me->fullname() . "<br />\n";
 +
 +echo "total ids: " . Person::$id . "<br />\n";
 +
 +?>
 +
 +<p>
 +== is like memcmp in C, it compares whole classes and attributes<br />
 +=== is like == in C, simply comparing references<br />
 +</p>
 +
 +</body>
 +</html>
 +
 +
 diff --git a/cms/content.php b/cms/content.php new file mode 100644 index 0000000..02ea225 --- /dev/null +++ b/cms/content.php @@ -0,0 +1,40 @@ +<?php
 +    error_reporting(E_ALL | E_STRICT);
 +    ini_set("display_errors", 1);
 +
 +    /* create connection */
 +    $connection = mysql_connect("localhost", "sandbox", "brotato333");
 +    if (!$connection)
 +        die("Could not connect to the database: " . mysql_error());
 +
 +    /* once you get the handle, select a database to use */
 +    $db_select = mysql_select_db("sandbox", $connection);
 +    if (!$db_select)
 +        die("Failed to select a database: " . mysql_error());
 +?>
 +
 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 +<html xmlns="http://www.w3.org/1999/xhtml">
 +<head>
 +<title>Hacker's Corner</title>
 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 +</head>
 +<body>
 +<h2>Hello, world!</h2>
 +<p>
 +<?php
 +    /* the return type is of resource, collection of rows essentially */
 +    $query = mysql_query("select * from subjects", $connection);
 +    if (!$query)
 +        die("Could not query: " . mysql_error());
 +
 +    while ($row = mysql_fetch_array($query)) /* for each row */
 +        echo $row[1] . " " . $row[2] . "<br />\n"; /* note, [0] would be the id field */
 +
 +    mysql_close($connection);
 +?>
 +</p>
 +</body>
 +</html>
 +
 diff --git a/cms/index.php b/cms/index.php new file mode 100644 index 0000000..02ea225 --- /dev/null +++ b/cms/index.php @@ -0,0 +1,40 @@ +<?php
 +    error_reporting(E_ALL | E_STRICT);
 +    ini_set("display_errors", 1);
 +
 +    /* create connection */
 +    $connection = mysql_connect("localhost", "sandbox", "brotato333");
 +    if (!$connection)
 +        die("Could not connect to the database: " . mysql_error());
 +
 +    /* once you get the handle, select a database to use */
 +    $db_select = mysql_select_db("sandbox", $connection);
 +    if (!$db_select)
 +        die("Failed to select a database: " . mysql_error());
 +?>
 +
 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 +<html xmlns="http://www.w3.org/1999/xhtml">
 +<head>
 +<title>Hacker's Corner</title>
 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 +</head>
 +<body>
 +<h2>Hello, world!</h2>
 +<p>
 +<?php
 +    /* the return type is of resource, collection of rows essentially */
 +    $query = mysql_query("select * from subjects", $connection);
 +    if (!$query)
 +        die("Could not query: " . mysql_error());
 +
 +    while ($row = mysql_fetch_array($query)) /* for each row */
 +        echo $row[1] . " " . $row[2] . "<br />\n"; /* note, [0] would be the id field */
 +
 +    mysql_close($connection);
 +?>
 +</p>
 +</body>
 +</html>
 +
 diff --git a/cms/staff.php b/cms/staff.php new file mode 100644 index 0000000..02ea225 --- /dev/null +++ b/cms/staff.php @@ -0,0 +1,40 @@ +<?php
 +    error_reporting(E_ALL | E_STRICT);
 +    ini_set("display_errors", 1);
 +
 +    /* create connection */
 +    $connection = mysql_connect("localhost", "sandbox", "brotato333");
 +    if (!$connection)
 +        die("Could not connect to the database: " . mysql_error());
 +
 +    /* once you get the handle, select a database to use */
 +    $db_select = mysql_select_db("sandbox", $connection);
 +    if (!$db_select)
 +        die("Failed to select a database: " . mysql_error());
 +?>
 +
 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 +<html xmlns="http://www.w3.org/1999/xhtml">
 +<head>
 +<title>Hacker's Corner</title>
 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 +</head>
 +<body>
 +<h2>Hello, world!</h2>
 +<p>
 +<?php
 +    /* the return type is of resource, collection of rows essentially */
 +    $query = mysql_query("select * from subjects", $connection);
 +    if (!$query)
 +        die("Could not query: " . mysql_error());
 +
 +    while ($row = mysql_fetch_array($query)) /* for each row */
 +        echo $row[1] . " " . $row[2] . "<br />\n"; /* note, [0] would be the id field */
 +
 +    mysql_close($connection);
 +?>
 +</p>
 +</body>
 +</html>
 +
 diff --git a/control.php b/control.php new file mode 100644 index 0000000..8e608e2 --- /dev/null +++ b/control.php @@ -0,0 +1,56 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 +<html xmlns="http://www.w3.org/1999/xhtml">
 +<head>
 +<title>Hacker's Corner</title>
 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 +</head>
 +<body>
 +<h1>Please Don't Fear!</h1>
 +<b>Sandbox:</b> Let's Roll!<br />
 +<p>
 +<?php
 +    error_reporting(E_ALL | E_STRICT);
 +    ini_set("display_errors", 1);
 +
 +    $pi = 3.14159;
 +    echo "Pi = " . $pi . "<br />";
 +
 +    switch ($pi)
 +    {
 +        case 1.618:
 +            break;
 +        case 3.14159:
 +            echo "cought it.<br />";
 +            break;
 +        default:
 +            echo "how could this happen?<br />";
 +            break;
 +    }
 +
 +    /* while and for are straightforward, foreach is interesting, it allows us
 +     * to loop through assosiative arrays, aka key-value pair */
 +    $myarr = array("world" => "evil", "bro" => "ski", "he" => "is good man");
 +    foreach ($myarr as $value)
 +        echo "the value is \"{$value}\"<br />";
 +
 +    echo "<br />";
 +    foreach ($myarr as $key => $value) /* fucking weird */
 +        echo "at {$key} the value is \"{$value}\"<br />";
 +
 +    echo '<br />$myarr points to "' . current($myarr) . "\".<br />";
 +    reset($myarr);
 +    next($myarr);
 +    echo '$myarr now points to "' . current($myarr) . "\".<br />";
 +
 +    /* incrementing pointer */
 +    while ($str = current($myarr))
 +    {
 +        echo $str . ", ";
 +        next($myarr);
 +    }
 +?>
 +</p>
 +</body>
 +</html>
 +
 diff --git a/databases.php b/databases.php new file mode 100644 index 0000000..02ea225 --- /dev/null +++ b/databases.php @@ -0,0 +1,40 @@ +<?php
 +    error_reporting(E_ALL | E_STRICT);
 +    ini_set("display_errors", 1);
 +
 +    /* create connection */
 +    $connection = mysql_connect("localhost", "sandbox", "brotato333");
 +    if (!$connection)
 +        die("Could not connect to the database: " . mysql_error());
 +
 +    /* once you get the handle, select a database to use */
 +    $db_select = mysql_select_db("sandbox", $connection);
 +    if (!$db_select)
 +        die("Failed to select a database: " . mysql_error());
 +?>
 +
 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 +<html xmlns="http://www.w3.org/1999/xhtml">
 +<head>
 +<title>Hacker's Corner</title>
 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 +</head>
 +<body>
 +<h2>Hello, world!</h2>
 +<p>
 +<?php
 +    /* the return type is of resource, collection of rows essentially */
 +    $query = mysql_query("select * from subjects", $connection);
 +    if (!$query)
 +        die("Could not query: " . mysql_error());
 +
 +    while ($row = mysql_fetch_array($query)) /* for each row */
 +        echo $row[1] . " " . $row[2] . "<br />\n"; /* note, [0] would be the id field */
 +
 +    mysql_close($connection);
 +?>
 +</p>
 +</body>
 +</html>
 +
 diff --git a/datatypes.php b/datatypes.php new file mode 100644 index 0000000..53e8678 --- /dev/null +++ b/datatypes.php @@ -0,0 +1,70 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 +<html xmlns="http://www.w3.org/1999/xhtml">
 +<head>
 +<title>Hacker's Corner</title>
 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 +</head>
 +<body>
 +<h1>Please Don't Fear!</h1>
 +<b>Sandbox:</b> Let's Roll!<br />
 +<p>
 +<?php
 +    error_reporting(E_ALL | E_STRICT);
 +    ini_set("display_errors", 1);
 +
 +    $pi = 3.14159;
 +    echo "Pi = " . $pi . "<br />";
 +
 +    $hellomsg = "Hello Kyle, world is good.<br />";
 +    /* note: single quotes would not do in place variable substitution */
 +    echo "{$hellomsg}"; /* weird, opposite of bash */
 +
 +    $myarray = array(12, 21, 33, 99, 33, "fox" /* hmm this is nice */, array("bro", "brotato"));
 +    echo "2nd item in our array is " . $myarray[1] . " " . $myarray[6][1] . ".<br /><br />";
 +
 +    /* key-value pairs, i like them, dejavu Lua! */
 +    $keyval = array("name" => "bro", "status" => "amused", "location" => "/dev/null");
 +    echo "$keyval[name] is $keyval[status]";
 +
 +    echo "</p><pre>";
 +    print_r($keyval);
 +    echo "</pre><br /><p>";
 +
 +    /* array into a string? seems heck useful */
 +    $str_from_arr = implode(" ~ ", $keyval); /* 1st param = glue */
 +    echo "the imploded array is: {$str_from_arr}";
 +?>
 +
 +<!-- just easier to type in html :p -->
 +<br />
 +Is Pi set?
 +    <?php
 +        if (isset($pi)) /* will catch undefined variables */
 +            echo "Yes" . "<br />";
 +        else
 +            echo "No" . "<br />";
 +
 +        /* how to escape? */
 +        $var1 = "\"brotato escaped\"";
 +        echo "escaped: " . $var1 . ", ha it is just like C!". "<br />";
 +
 +        unset($pi); /* why not just set it to null? we can set it to 0, "0"! and null */
 +        if (empty($pi))
 +            echo "Pi has been unset.<br />";
 +    ?>
 +<br />
 +Typecasting, <b>php is very clever!</b><br />
 +    <?php
 +        $pi = 3.14159;
 +        $piphi = $pi + "1.618 i love this number";
 +        echo "piphi is of type " . gettype($piphi) . " and equals to {$piphi}.<br />";
 +        settype($piphi, "string"); /* or just typecast, (string) in front ? */
 +
 +        /* constants */
 +        define("PI_VAL", 3.14159);
 +    ?>
 +</p>
 +</body>
 +</html>
 +
 diff --git a/dtime_format.php b/dtime_format.php new file mode 100644 index 0000000..9048ce6 --- /dev/null +++ b/dtime_format.php @@ -0,0 +1,21 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 +<html xmlns="http://www.w3.org/1999/xhtml">
 +<head>
 +<title>Hacker's Corner</title>
 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 +</head>
 +<body>
 +<h2>Beyond The Basics?</h2>
 +<?php
 +    $timestamp = time();
 +    echo strftime("today date is %m/%d/%y", $timestamp) . "<br />\n";
 +    echo "<hr />\n";
 +
 +    $dt = time();
 +    $mysql_datetime = strftime("%Y-%m-%d %H:%M:%S", $dt);
 +    echo "mysql format that it understands: {$mysql_datetime}" . "<br />\n";
 +?>
 +</body>
 +</html>
 +
 diff --git a/dtime_unix.php b/dtime_unix.php new file mode 100644 index 0000000..2a93911 --- /dev/null +++ b/dtime_unix.php @@ -0,0 +1,23 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 +<html xmlns="http://www.w3.org/1999/xhtml">
 +<head>
 +<title>Hacker's Corner</title>
 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 +</head>
 +<body>
 +<h2>Beyond The Basics?</h2>
 +<p>
 +seconds elapsed since midnight Jan 1,1970: 
 +<?php
 +    echo time() . "<br />\n";
 +    echo "Sep 22, 2008 was this many seconds since the epoch: " . mktime(8, 18, 0, 9, 22, 2008) . "<br />\n";
 +    echo "Is Dec 82, 2012 a valid date? " . (checkdate(12, 82, 2012) ? "Yes" : "No") . "<br />\n"; /* zawiasy */
 +
 +    $tstamp = strtotime("2 years ago");
 +    echo "2 years ago bro: {$tstamp}<br />\n"
 +?>
 +</p>
 +</body>
 +</html>
 +
 diff --git a/dynaval.php b/dynaval.php new file mode 100644 index 0000000..470ab49 --- /dev/null +++ b/dynaval.php @@ -0,0 +1,23 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 +<html xmlns="http://www.w3.org/1999/xhtml">
 +<head>
 +<title>Hacker's Corner</title>
 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 +</head>
 +<body>
 +<h1>Beyond The Basics?</h1>
 +<p>
 +<?php
 +    $a = "bro";
 +    $b = "bro bro";
 +    $c = "brotato";
 +
 +    $arr = array("a", "b", "c");
 +    foreach ($arr as $tok)
 +        echo $$tok . "<br />\n";
 +?>
 +</p>
 +</body>
 +</html>
 +
 diff --git a/encoding.php b/encoding.php new file mode 100644 index 0000000..36ae6f8 --- /dev/null +++ b/encoding.php @@ -0,0 +1,26 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 +<html xmlns="http://www.w3.org/1999/xhtml">
 +<head>
 +<title>Hacker's Corner</title>
 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 +</head>
 +<body>
 +<h2>In Soviet Russia the university fails you!</h2>
 +<p>
 +<?php
 +    $url_page = '~sandbox/request.php';
 +    $param = "pc.jpg";
 +    $text = 'launch me! #$$#Y$T&@ <fool>'; /* I think you want single quotes here */
 +
 +    $url = "http://kkaminsk.com/";
 +    $url .= rawurlencode($url_page);
 +    $url .= "?id=" . urlencode($param);
 +?>
 +For some reason this didn't work for me at the time, Apache?<br />
 +<a href="<?php echo htmlspecialchars($url); ?>">
 +<?php echo htmlspecialchars($text); ?></a>
 +</p>
 +</body>
 +</html>
 +
 diff --git a/example.html b/example.html new file mode 100644 index 0000000..a245829 --- /dev/null +++ b/example.html @@ -0,0 +1,30 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 +<html xmlns="http://www.w3.org/1999/xhtml">
 +<head>
 +<title>Brotato</title>
 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 +<style type="text/css">
 +body { background-color: gray } <!-- /* element selector */ -->
 +#brostyle { text-align: center }
 +.colorful { color: lime }
 +</style>
 +</head>
 +
 +<body>
 +<div id="brostyle">
 +<h2>Broski</h2>
 +<p class="colorful">sprintf(buff, "goodbye world, %s", "bro");</p>
 +<p>
 +Cascading Style Sheets (CSS) is a style sheet language used to describe the
 +presentation semantics (the look and formatting) of a document written in a
 +markup language. Its most common application is to style web pages written in
 +HTML and XHTML, but the language can also be applied to any kind of XML
 +document, including plain XML, SVG and XUL.
 +</p>
 +</div>
 +
 +<img src="files/soldering.jpg" alt="soldering bro, mad skills" style="height: 480px" />
 +
 +</body>
 +</html>
 diff --git a/fetch.php b/fetch.php new file mode 100644 index 0000000..e7afc2c --- /dev/null +++ b/fetch.php @@ -0,0 +1,36 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 +<html xmlns="http://www.w3.org/1999/xhtml">
 +<head>
 +<title>Hacker's Corner</title>
 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 +</head>
 +<body>
 +<h1>Please Don't Fear!</h1>
 +<b>Sandbox:</b> Fuk the Fetch!<br />
 +<h2>In Soviet Russia the university fails you!</h2>
 +<p>
 +<?php
 +    error_reporting(E_ALL | E_STRICT);
 +    ini_set("display_errors", 1);
 +
 +    echo "<a href=\"request.php?id=decap.jpg\">Fetch Decapped Injectors</a><br />\n";
 +    echo "<a href=\"request.php?id=pc.jpg\">Fetch a PC</a><br />\n";
 +    /* this one has spaces, hence we use url encoding, only needed for GET */
 +    echo "<a href=\"request.php?id=" . urlencode("dave at garage.jpg") . "\">Dave</a><br />\n";
 +    /* raw url would use %20 instead of a + for a space, raw is used in url too the left of ?
 +     * also, apache would insert %20 for us without using urlencode, but we should no rely on this */
 +
 +    echo "<a href=\"request.php?id=code.jpg\">" . htmlspecialchars("teh code & my <lab>") . "</a>\n";
 +?>
 +</p>
 +<p>
 +Raw URL<br />
 +<?php
 +    $raw_url = rawurlencode("omfg terabyte ram helluva low latency iz in my h4x0red pc");
 +    echo $raw_url . "<br />\n";
 +?>
 +</p>
 +</body>
 +</html>
 +
 diff --git a/files/code.jpg b/files/code.jpg Binary files differnew file mode 100644 index 0000000..05692c9 --- /dev/null +++ b/files/code.jpg diff --git a/files/dave at garage.jpg b/files/dave at garage.jpg Binary files differnew file mode 100644 index 0000000..fa2d506 --- /dev/null +++ b/files/dave at garage.jpg diff --git a/files/decap.jpg b/files/decap.jpg Binary files differnew file mode 100644 index 0000000..e72c453 --- /dev/null +++ b/files/decap.jpg diff --git a/files/pc.jpg b/files/pc.jpg Binary files differnew file mode 100644 index 0000000..4b27a1c --- /dev/null +++ b/files/pc.jpg diff --git a/files/soldering.jpg b/files/soldering.jpg Binary files differnew file mode 100644 index 0000000..4de7c5d --- /dev/null +++ b/files/soldering.jpg diff --git a/forms.php b/forms.php new file mode 100644 index 0000000..1fc9b88 --- /dev/null +++ b/forms.php @@ -0,0 +1,51 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 +<html xmlns="http://www.w3.org/1999/xhtml">
 +<head>
 +<title>Hacker's Corner</title>
 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 +</head>
 +<body>
 +<h2>In Soviet Russia the server GETs you!</h2>
 +
 +<form action="process.php" method="post" name="login">
 +  User: <input type="text" name="name" value="guest" /><br />
 +  Password: <input type="password" name="password" value="evil" /><br />
 +  <input type="submit" value="Submit" />
 +</form>
 +
 +<br />
 +
 +<form action="process.php" method="get" name="userinfo">
 +  Name: <input type="text" name="name" value="hax0r" /><br />
 +  Password: <input type="text" name="password" value="evil" /><br />
 +  E-mail: <input type="text" name="email" value="hax0r@hax.com" /><br />
 +  Location: <input type="text" name="location" value="127.0.0.1" /><br />
 +  Home Phone: <input type="text" name="home_phone" value="911" /><br />
 +  Work Phone: <input type="text" name="work_phone" value="111" /><br />
 +  <input type="hidden" name="FormName" value="Record" />
 +  <input type="hidden" name="FormAction" value="insert" />
 +  <input type="submit" value="Submit" />
 +</form>
 +
 +<br />
 +
 +<form action="insert.php" method="post">
 +  Subject name: <input type="text" name="menu_name" value="" id="menu_name" /><br />
 +  Position: <select name="position">
 +        <option value="1">1</option> <!-- was really meant to insert at specific place -->
 +        <option value="2">2</option> <!-- and push off existing ones by 1 offset -->
 +        <option value="3">3</option>
 +  </select><br />
 +  Visible: <input type="radio" name="visible" value="0" /> No   <input type="radio" name="visible" value="1" /> Yes<br />
 +  <input type="submit" value="Add Subject" />
 +</form>
 +
 +<p>
 +<?php /* on errors the form should submit to itself */
 +?>
 +</p>
 +
 +</body>
 +</html>
 +
 diff --git a/functions.php b/functions.php new file mode 100644 index 0000000..b6bb5f3 --- /dev/null +++ b/functions.php @@ -0,0 +1,56 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 +<html xmlns="http://www.w3.org/1999/xhtml">
 +<head>
 +<title>Hacker's Corner</title>
 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 +</head>
 +<body>
 +<h1>Please Don't Fear!</h1>
 +<b>Sandbox:</b> Let's Roll!<br />
 +<p>
 +    <?php
 +        error_reporting(E_ALL | E_STRICT);
 +        ini_set("display_errors", 1);
 +
 +        /* pass by reference, otherwise arguments get duped */
 +        function calc_square(&$var)
 +        {
 +            $var *= $var;
 +        }
 +
 +        function num_raised(&$var, $base = 2, $pow = 3) /* yeah */
 +        {
 +            $var = 1;
 +            while ($pow--)
 +                $var *= $base;
 +        }
 +
 +        /* unlike Lua, we have to pass all arguments to the functions */
 +        function print_pi($str)
 +        {
 +            $pi = 3.14159;
 +            return "Pi = " . $pi . " " . $str . ".<br />";
 +        }
 +
 +        echo print_pi("brotato");
 +
 +        $number = 11;
 +        calc_square($number);
 +        echo "a square of 11 is " . $number . ".<br />";
 +
 +        $number2 = NULL; /* nice to know how to modiy a variable */
 +        num_raised($number2, 2, 4);
 +        echo "a cube of 2 is " . $number2 . ".<br />";
 +        var_dump($number2);
 +    ?>
 +</p>
 +    <p>PHP defined variables including mine.</p>
 +<pre>
 +    <?php
 +        print_r(get_defined_vars());
 +    ?>
 +</pre>
 +</body>
 +</html>
 +
 diff --git a/headers.php b/headers.php new file mode 100644 index 0000000..edf0df5 --- /dev/null +++ b/headers.php @@ -0,0 +1,24 @@ +<?php
 +    header("Location: hello.php"); /* 302 redirect */
 +    //header("HTTP/1.0 404 Not Found"); /* still not sure how useful this is */
 +    /* ah, could redirect, or when using readfile(), poke the browser to pop-up save dialog */
 +
 +    exit(0); /* you want this */
 +?>
 +
 +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 +<html xmlns="http://www.w3.org/1999/xhtml">
 +<head>
 +<title>Hacker's Corner</title>
 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 +</head>
 +<body>
 +<h2>Hello, world!</h2>
 +<p>
 +<?php
 +?>
 +</p>
 +</body>
 +</html>
 +
 diff --git a/hello.php b/hello.php new file mode 100644 index 0000000..aba39d4 --- /dev/null +++ b/hello.php @@ -0,0 +1,19 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>Hacker's Corner</title> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +</head> +<body> +<h1>Please Don't Fear!</h1> +<b>Sandbox:</b> Let's Roll!<br /> +<p> +<?php +    /* comments are same as C bro */ +    echo "Hello PHP!"; +?> +</p> +</body> +</html> + diff --git a/included_func.php b/included_func.php new file mode 100644 index 0000000..8a5cb10 --- /dev/null +++ b/included_func.php @@ -0,0 +1,8 @@ +<?php
 +    function va_func()
 +    {
 +        $args = func_get_args();
 +        foreach ($args as $k => $v)
 +            echo "arg" . ($k + 1) . ": {$v}<br />\n";
 +    }
 +?>
 diff --git a/includes.php b/includes.php new file mode 100644 index 0000000..61a28d9 --- /dev/null +++ b/includes.php @@ -0,0 +1,19 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 +<html xmlns="http://www.w3.org/1999/xhtml">
 +<head>
 +<title>Hacker's Corner</title>
 +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 +</head>
 +<body>
 +<h2>Hello, world!</h2>
 +<p>
 +<?php
 +    include_once("included_func.php");
 +    va_func("look", "i passed", "many arguments", "to a function",
 +            "pretty easy", "and awesome");
 +?>
 +</p>
 +</body>
 +</html>
 +
 diff --git a/insert.php b/insert.php<  | 
