From 1bad4fc00814e2c03ecadaa7faf93c6372f5bd30 Mon Sep 17 00:00:00 2001 From: Kyle Kaminski Date: Sun, 16 Jun 2013 03:25:26 -0500 Subject: initial commit --- arrfuncs.php | 41 +++++++++++++ class_ex.php | 72 ++++++++++++++++++++++ cms/content.php | 40 ++++++++++++ cms/index.php | 40 ++++++++++++ cms/staff.php | 40 ++++++++++++ control.php | 56 +++++++++++++++++ databases.php | 40 ++++++++++++ datatypes.php | 70 +++++++++++++++++++++ dtime_format.php | 21 +++++++ dtime_unix.php | 23 +++++++ dynaval.php | 23 +++++++ encoding.php | 26 ++++++++ example.html | 30 +++++++++ fetch.php | 36 +++++++++++ files/code.jpg | Bin 0 -> 132090 bytes files/dave at garage.jpg | Bin 0 -> 122260 bytes files/decap.jpg | Bin 0 -> 96050 bytes files/pc.jpg | Bin 0 -> 137228 bytes files/soldering.jpg | Bin 0 -> 215880 bytes forms.php | 51 ++++++++++++++++ functions.php | 56 +++++++++++++++++ headers.php | 24 ++++++++ hello.php | 19 ++++++ included_func.php | 8 +++ includes.php | 19 ++++++ insert.php | 75 +++++++++++++++++++++++ process.php | 53 ++++++++++++++++ reference.php | 29 +++++++++ request.php | 22 +++++++ scope.php | 50 +++++++++++++++ server_req_vars.php | 32 ++++++++++ session.php | 31 ++++++++++ wmlcards.html | 156 +++++++++++++++++++++++++++++++++++++++++++++++ 33 files changed, 1183 insertions(+) create mode 100644 arrfuncs.php create mode 100644 class_ex.php create mode 100644 cms/content.php create mode 100644 cms/index.php create mode 100644 cms/staff.php create mode 100644 control.php create mode 100644 databases.php create mode 100644 datatypes.php create mode 100644 dtime_format.php create mode 100644 dtime_unix.php create mode 100644 dynaval.php create mode 100644 encoding.php create mode 100644 example.html create mode 100644 fetch.php create mode 100644 files/code.jpg create mode 100644 files/dave at garage.jpg create mode 100644 files/decap.jpg create mode 100644 files/pc.jpg create mode 100644 files/soldering.jpg create mode 100644 forms.php create mode 100644 functions.php create mode 100644 headers.php create mode 100644 hello.php create mode 100644 included_func.php create mode 100644 includes.php create mode 100644 insert.php create mode 100644 process.php create mode 100644 reference.php create mode 100644 request.php create mode 100644 scope.php create mode 100644 server_req_vars.php create mode 100644 session.php create mode 100644 wmlcards.html diff --git a/arrfuncs.php b/arrfuncs.php new file mode 100644 index 0000000..3595b99 --- /dev/null +++ b/arrfuncs.php @@ -0,0 +1,41 @@ + + + +Hacker's Corner + + + +

Beyond The Basics?

+

+shift and unshift chops/prepends the beginning of the array
+
\n"; + + /* shift a value from an array */ + $a = array_shift($arr); + echo $a . "

\n"; + + /* unshift an element, this func returns the element count */ + $c = array_unshift($arr, $a); + print_r($arr); + echo "

\n"; +?> + +pop and push
+
\n"; + + /* push back an element, this func returns the element count */ + $c = array_push($arr, "foo"); + $c = array_push($arr, "bar"); + print_r($arr); +?> +

+ + + 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 @@ + + + +Hacker's Corner + + + +

Beyond The Basics?

+ +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() . "
\n"; + +$me = clone $person; +$me->lname = "K"; +echo $me->fullname() . "
\n"; + +echo "total ids: " . Person::$id . "
\n"; + +?> + +

+== is like memcmp in C, it compares whole classes and attributes
+=== is like == in C, simply comparing references
+

+ + + + + 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 @@ + + + + + +Hacker's Corner + + + +

Hello, world!

+

+\n"; /* note, [0] would be the id field */ + + mysql_close($connection); +?> +

+ + + 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 @@ + + + + + +Hacker's Corner + + + +

Hello, world!

+

+\n"; /* note, [0] would be the id field */ + + mysql_close($connection); +?> +

+ + + 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 @@ + + + + + +Hacker's Corner + + + +

Hello, world!

+

+\n"; /* note, [0] would be the id field */ + + mysql_close($connection); +?> +

+ + + diff --git a/control.php b/control.php new file mode 100644 index 0000000..8e608e2 --- /dev/null +++ b/control.php @@ -0,0 +1,56 @@ + + + +Hacker's Corner + + + +

Please Don't Fear!

+Sandbox: Let's Roll!
+

+"; + + switch ($pi) + { + case 1.618: + break; + case 3.14159: + echo "cought it.
"; + break; + default: + echo "how could this happen?
"; + 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}\"
"; + + echo "
"; + foreach ($myarr as $key => $value) /* fucking weird */ + echo "at {$key} the value is \"{$value}\"
"; + + echo '
$myarr points to "' . current($myarr) . "\".
"; + reset($myarr); + next($myarr); + echo '$myarr now points to "' . current($myarr) . "\".
"; + + /* incrementing pointer */ + while ($str = current($myarr)) + { + echo $str . ", "; + next($myarr); + } +?> +

+ + + diff --git a/databases.php b/databases.php new file mode 100644 index 0000000..02ea225 --- /dev/null +++ b/databases.php @@ -0,0 +1,40 @@ + + + + + +Hacker's Corner + + + +

Hello, world!

+

+\n"; /* note, [0] would be the id field */ + + mysql_close($connection); +?> +

+ + + diff --git a/datatypes.php b/datatypes.php new file mode 100644 index 0000000..53e8678 --- /dev/null +++ b/datatypes.php @@ -0,0 +1,70 @@ + + + +Hacker's Corner + + + +

Please Don't Fear!

+Sandbox: Let's Roll!
+

+"; + + $hellomsg = "Hello Kyle, world is good.
"; + /* 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] . ".

"; + + /* key-value pairs, i like them, dejavu Lua! */ + $keyval = array("name" => "bro", "status" => "amused", "location" => "/dev/null"); + echo "$keyval[name] is $keyval[status]"; + + echo "

";
+    print_r($keyval);
+    echo "

"; + + /* array into a string? seems heck useful */ + $str_from_arr = implode(" ~ ", $keyval); /* 1st param = glue */ + echo "the imploded array is: {$str_from_arr}"; +?> + + +
+Is Pi set? + "; + else + echo "No" . "
"; + + /* how to escape? */ + $var1 = "\"brotato escaped\""; + echo "escaped: " . $var1 . ", ha it is just like C!". "
"; + + 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.
"; + ?> +
+Typecasting, php is very clever!
+ "; + settype($piphi, "string"); /* or just typecast, (string) in front ? */ + + /* constants */ + define("PI_VAL", 3.14159); + ?> +

+ + + 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 @@ + + + +Hacker's Corner + + + +

Beyond The Basics?

+\n"; + echo "
\n"; + + $dt = time(); + $mysql_datetime = strftime("%Y-%m-%d %H:%M:%S", $dt); + echo "mysql format that it understands: {$mysql_datetime}" . "
\n"; +?> + + + 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 @@ + + + +Hacker's Corner + + + +

Beyond The Basics?

+

+seconds elapsed since midnight Jan 1,1970: +\n"; + echo "Sep 22, 2008 was this many seconds since the epoch: " . mktime(8, 18, 0, 9, 22, 2008) . "
\n"; + echo "Is Dec 82, 2012 a valid date? " . (checkdate(12, 82, 2012) ? "Yes" : "No") . "
\n"; /* zawiasy */ + + $tstamp = strtotime("2 years ago"); + echo "2 years ago bro: {$tstamp}
\n" +?> +

+ + + diff --git a/dynaval.php b/dynaval.php new file mode 100644 index 0000000..470ab49 --- /dev/null +++ b/dynaval.php @@ -0,0 +1,23 @@ + + + +Hacker's Corner + + + +

Beyond The Basics?

+

+\n"; +?> +

+ + + diff --git a/encoding.php b/encoding.php new file mode 100644 index 0000000..36ae6f8 --- /dev/null +++ b/encoding.php @@ -0,0 +1,26 @@ + + + +Hacker's Corner + + + +

In Soviet Russia the university fails you!

+

+'; /* 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?
+ + +

+ + + diff --git a/example.html b/example.html new file mode 100644 index 0000000..a245829 --- /dev/null +++ b/example.html @@ -0,0 +1,30 @@ + + + +Brotato + + + + + +
+

Broski

+

sprintf(buff, "goodbye world, %s", "bro");

+

+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. +

+
+ +soldering bro, mad skills + + + diff --git a/fetch.php b/fetch.php new file mode 100644 index 0000000..e7afc2c --- /dev/null +++ b/fetch.php @@ -0,0 +1,36 @@ + + + +Hacker's Corner + + + +

Please Don't Fear!

+Sandbox: Fuk the Fetch!
+

In Soviet Russia the university fails you!

+

+Fetch Decapped Injectors
\n"; + echo "Fetch a PC
\n"; + /* this one has spaces, hence we use url encoding, only needed for GET */ + echo "Dave
\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 "" . htmlspecialchars("teh code & my ") . "\n"; +?> +

+

+Raw URL
+\n"; +?> +

+ + + diff --git a/files/code.jpg b/files/code.jpg new file mode 100644 index 0000000..05692c9 Binary files /dev/null and b/files/code.jpg differ diff --git a/files/dave at garage.jpg b/files/dave at garage.jpg new file mode 100644 index 0000000..fa2d506 Binary files /dev/null and b/files/dave at garage.jpg differ diff --git a/files/decap.jpg b/files/decap.jpg new file mode 100644 index 0000000..e72c453 Binary files /dev/null and b/files/decap.jpg differ diff --git a/files/pc.jpg b/files/pc.jpg new file mode 100644 index 0000000..4b27a1c Binary files /dev/null and b/files/pc.jpg differ diff --git a/files/soldering.jpg b/files/soldering.jpg new file mode 100644 index 0000000..4de7c5d Binary files /dev/null and b/files/soldering.jpg differ diff --git a/forms.php b/forms.php new file mode 100644 index 0000000..1fc9b88 --- /dev/null +++ b/forms.php @@ -0,0 +1,51 @@ + + + +Hacker's Corner + + + +

In Soviet Russia the server GETs you!

+ +
+ User:
+ Password:
+ +
+ +
+ +
+ Name:
+ Password:
+ E-mail:
+ Location:
+ Home Phone:
+ Work Phone:
+ + + +
+ +
+ +
+ Subject name:
+ Position:
+ Visible: No   Yes
+ +
+ +

+ +

+ + + + diff --git a/functions.php b/functions.php new file mode 100644 index 0000000..b6bb5f3 --- /dev/null +++ b/functions.php @@ -0,0 +1,56 @@ + + + +Hacker's Corner + + + +

Please Don't Fear!

+Sandbox: Let's Roll!
+

+ "; + } + + echo print_pi("brotato"); + + $number = 11; + calc_square($number); + echo "a square of 11 is " . $number . ".
"; + + $number2 = NULL; /* nice to know how to modiy a variable */ + num_raised($number2, 2, 4); + echo "a cube of 2 is " . $number2 . ".
"; + var_dump($number2); + ?> +

+

PHP defined variables including mine.

+
+    
+
+ + + diff --git a/headers.php b/headers.php new file mode 100644 index 0000000..edf0df5 --- /dev/null +++ b/headers.php @@ -0,0 +1,24 @@ + + + + + +Hacker's Corner + + + +

Hello, world!

+

+ +

+ + + diff --git a/hello.php b/hello.php new file mode 100644 index 0000000..aba39d4 --- /dev/null +++ b/hello.php @@ -0,0 +1,19 @@ + + + +Hacker's Corner + + + +

Please Don't Fear!

+Sandbox: Let's Roll!
+

+ +

+ + + 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 @@ + $v) + echo "arg" . ($k + 1) . ": {$v}
\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 @@ + + + +Hacker's Corner + + + +

Hello, world!

+

+ +

+ + + diff --git a/insert.php b/insert.php new file mode 100644 index 0000000..f3c9652 --- /dev/null +++ b/insert.php @@ -0,0 +1,75 @@ + + + + + +Hacker's Corner + + + +

Fire fire fire!

+ 30); + if (empty($menu_name) || !validation($requirements, $_POST) || !isset($_POST['visible'])) /* visible is a boolean AFAIK */ + { + header("Location: forms.php"); + exit; + } + + /* string needs single quotes */ + $query = "insert into subjects ( + menu_name, position, visible + ) VALUES ( + '{$menu_name}', {$position}, {$visible} + )"; + + $result = mysql_query($query, $connection); + if ($result) + { + header("Location: fetch.php"); + exit; + } + else + { + echo "

Subject creation failed.

\n"; + echo "

" . mysql_error() . "

\n"; + } + + /* kinda went freestyle, check to make sure not overflow the sql */ + function validation($rules, $source) + { + foreach ($rules as $rule => $max_length) + { + if (strlen($source[$rule]) > $max_length) + { + echo "{$rule} is over {$max_length} characters long!
\n"; + return false; + } + } + + return true; + } + + mysql_close($connection); +?> + + + diff --git a/process.php b/process.php new file mode 100644 index 0000000..84fdb0b --- /dev/null +++ b/process.php @@ -0,0 +1,53 @@ + + + +Hacker's Corner + + + +

In Soviet Russia the server FETCHES you!

+ +

+\n"; + + /* just close the php tag and write in html, why complicate? */ + $table = "\n" . + " \n" . + " \n" . + " \n" . + " \n" . + " \n" . + " \n" . + "
NamePassword
{$_POST['name']}{$_POST['password']}
\n"; + echo "{$table}
\n"; + } + /* GET */ + if (!empty($_GET)) + { + /* heredoc? */ +$table = << + + + + + + + +
TokenValue
Name{$_GET['name']}
Password{$_GET['password']}
E-mail{$_GET['email']}
Location{$_GET['location']}
Home Phone{$_GET['home_phone']}
Work Phone{$_GET['work_phone']}
+EOD; + echo "{$table}
\n"; + } +?> +

+ + + + diff --git a/reference.php b/reference.php new file mode 100644 index 0000000..b1cf789 --- /dev/null +++ b/reference.php @@ -0,0 +1,29 @@ + + + +Hacker's Corner + + + +\n"; + echo $ref . "

\n"; + + $ref++; + echo $num . "
\n"; + echo $ref . "
\n"; +?> + + + diff --git a/request.php b/request.php new file mode 100644 index 0000000..4495baf --- /dev/null +++ b/request.php @@ -0,0 +1,22 @@ + + + +Hacker's Corner + + + +

Please Don't Fear!

+Sandbox: Teh Request!
+

+
"; + echo "\"bro!\""; +?> +

+ + + diff --git a/scope.php b/scope.php new file mode 100644 index 0000000..fc25ce4 --- /dev/null +++ b/scope.php @@ -0,0 +1,50 @@ + + + +Hacker's Corner + + + +\n"; + } + + function test2() + { + global $var; /* extern */ + $var = 2; /* now we actually change the global */ + echo $var . "
\n"; + } + + function test3() + { + /* local var with ability to retain value in multiple calls */ + static $var = 0; + + echo "test3 var: {$var}
\n"; + $var++; + } + + test1(); + echo $var . "

\n"; + + test2(); + echo $var . "
\n"; + + test3(); + test3(); + test3(); + test3(); + test3(); + echo $var; +?> + + + diff --git a/server_req_vars.php b/server_req_vars.php new file mode 100644 index 0000000..f2f9845 --- /dev/null +++ b/server_req_vars.php @@ -0,0 +1,32 @@ + + + +Hacker's Corner + + + +Server details\n"; + echo "SERVER_NAME: {$_SERVER['SERVER_NAME']}
\n"; + echo "SERVER_ADDR: {$_SERVER['SERVER_ADDR']}
\n"; + echo "SERVER_PORT: {$_SERVER['SERVER_PORT']}
\n"; + echo "DOCUMENT_ROOT: {$_SERVER['DOCUMENT_ROOT']}
\n"; + + echo "

Page details

\n"; + echo "PHP_SELF: {$_SERVER['PHP_SELF']}
\n"; + echo "SCRIPT_FILENAME: {$_SERVER['SCRIPT_FILENAME']}
\n"; + + echo "

Request details

\n"; + echo "REMOTE_ADDR: {$_SERVER['REMOTE_ADDR']}
\n"; + echo "REMOTE_PORT: {$_SERVER['REMOTE_PORT']}
\n"; + echo "REQUEST_URI: {$_SERVER['REQUEST_URI']}
\n"; + echo "QUERY_STRING: {$_SERVER['QUERY_STRING']}
\n"; + echo "REQUEST_METHOD: {$_SERVER['REQUEST_METHOD']}
\n"; + echo "REQUEST_TIME: {$_SERVER['REQUEST_TIME']}
\n"; + echo "HTTP_REFERER: {$_SERVER['HTTP_REFERER']}
\n"; + echo "HTTP_USER_AGENT: {$_SERVER['HTTP_USER_AGENT']}
\n"; +?> + + + diff --git a/session.php b/session.php new file mode 100644 index 0000000..6125b17 --- /dev/null +++ b/session.php @@ -0,0 +1,31 @@ + + + + + +Hacker's Corner + + + +

Phi = 1.618

+

+ +\n"; +?> +

+ + + diff --git a/wmlcards.html b/wmlcards.html new file mode 100644 index 0000000..ba174ec --- /dev/null +++ b/wmlcards.html @@ -0,0 +1,156 @@ + + + + + Anchor Jumps + + + + + + + +
+

Card 1

+

This is Card 1.

+ Here is just some text below Card 1.
+ More text to kill window space.
+ +
+ +
+ +
+ +
+

Card 2

+

This is Card 2.

+ Here is just some text below Card 2.
+ More text to kill window space.
+ +
+ +
+
+ +
+

Card 3

+

This is Card 3.

+ Here is just some text below Card 3.
+ More text to kill window space.
+ +
+ +
+
+ +
+

Card 4

+

This is Card 4.

+ Here is just some text below Card 4.
+ More text to kill window space.
+ Go to Card 6
+ +
+ +
+
+ +
+

Card 5

+

This is Card 5.

+ Here is just some text below Card 5.
+ More text to kill window space.
+ +
+ +
+
+ +
+

Card 6

+

This is Card 6.

+ Here is just some text below Card 6.
+ More text to kill window space.
+ +
+ +
+
+ +
+

Card 7

+

This is Card 7.

+ Here is just some text below Card 7.
+ More text to kill window space.
+ +
+ +
+
+ + + -- cgit v1.2.3