Skip to content

Commit cb7a630

Browse files
committed
style updates
instructions page improve credits add includes.php functionality
1 parent 6847d05 commit cb7a630

File tree

5 files changed

+137
-14
lines changed

5 files changed

+137
-14
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/.settings
22
/.buildpath
33
/.project
4+
/includes.php

assets/images/function.png

382 Bytes
Loading

credits.php

+22-6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
</div>
3737
<div id="navbar" class="collapse navbar-collapse">
3838
<ul class="nav navbar-nav">
39+
<li><a href="./">Browser</a></li>
40+
<li><a href="instructions.php">Instructions</a></li>
41+
<li class="active"><a href="credits.php">Credits</a></li>
3942
</ul>
4043
</div><!--/.nav-collapse -->
4144
</div>
@@ -44,17 +47,30 @@
4447
<main class="container">
4548

4649
<h1>Credits</h1>
47-
<div>Designed by <a href="http://verysimple.com">Jason Hinkle</a></div>
48-
<div>Treeview by <a href="http://www.jstree.com/">jsTree</a></div>
49-
<div>CSS by <a href="http://getbootstrap.com">Bootstrap</a></div>
50-
<div>Font Icons by <a href="http://fortawesome.github.io/Font-Awesome/">Font Awesome</a></div>
51-
<div>Image Icons by <a href="http://www.flaticon.com/packs/font-awesome">flaticon.com</a></div>
50+
<p>Created by <a href="http://verysimple.com">Jason Hinkle</a></p>
51+
52+
53+
<h3>Props To</h3>
54+
<div><i class="fa fa-thumbs-o-up"></i> Treeview by <a href="http://www.jstree.com/">jsTree</a> (MIT License)</div>
55+
<div><i class="fa fa-thumbs-o-up"></i> CSS by <a href="http://getbootstrap.com">Bootstrap</a> (MIT License)</div>
56+
<div><i class="fa fa-thumbs-o-up"></i> Font Icons by <a href="http://fortawesome.github.io/Font-Awesome/">Font Awesome</a> (CC License)</div>
57+
<div><i class="fa fa-thumbs-o-up"></i> Image Icons by <a href="http://www.flaticon.com/packs/font-awesome">flaticon.com</a> (CC License)</div>
58+
59+
<h3>License</h3>
60+
<?php
61+
62+
if (is_file('LICENSE') && is_readable('LICENSE')) {
63+
$license = file_get_contents('LICENSE');
64+
echo "<pre>$license</pre>";;
65+
}
66+
67+
?>
5268

5369
</main>
5470

5571
<footer class="footer">
5672
<div class="container">
57-
<div class="text-muted">Created out of spite by <a href="http://verysimple.com/">Jason Hinkle</a> - <a href="credits.php">Credits</a></div>
73+
<div class="text-muted">Created out of spite by <a href="http://verysimple.com/">Jason Hinkle</a></div>
5874
</div>
5975
</footer>
6076

index.php

+29-8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
</div>
3737
<div id="navbar" class="collapse navbar-collapse">
3838
<ul class="nav navbar-nav">
39+
<li class="active"><a href="./">Browser</a></li>
40+
<li><a href="instructions.php">Instructions</a></li>
41+
<li><a href="credits.php">Credits</a></li>
3942
</ul>
4043
</div><!--/.nav-collapse -->
4144
</div>
@@ -44,6 +47,11 @@
4447
<main class="container">
4548
<?php
4649

50+
if (is_file('includes.php') && is_readable('includes.php')) {
51+
require_once 'includes.php';
52+
echo '<div class="alert alert-info"><i class="fa fa-info-circle"></i> Class definitions from includes.php loaded.</div>';
53+
}
54+
4755
define('RECURSION_SANITY_LIMIT',25);
4856
define('BASE_URL', str_replace('index.php', '', full_url($_SERVER)));
4957
error_reporting(E_ALL & ~E_NOTICE);
@@ -66,16 +74,13 @@
6674
}
6775
}
6876
else {
69-
echo '<div class="alert alert-danger"><strong>Warning:</strong> This app can be used to run arbitrary code. Do not install it on an unprotected, public server.</div>
70-
<div id="form-container">
77+
echo '<div id="form-container">
7178
<form action="index.php" method="post">
72-
<h5>PHP Object To Inspect:</h5>
79+
<h3>PHP Object To Inspect:</h3>
7380
<p id="data-container"><textarea class="form-control" name="data" id="data" placeholder="Copy/paste serialized PHP code here"></textarea></p>
7481
<p id="submit-container"><input class="btn btn-primary" type="submit" value="Let\'s Do This..."></p>
7582
</form>
7683
</div>
77-
<h5 class="top-buffer">Example serialized code:</h5>
78-
<pre>O:8:"stdClass":2:{s:4:"name";s:16:"This is a string";s:4:"data";a:2:{s:4:"size";i:50;s:5:"color";s:5:"green";}}</pre>
7984
';
8085
}
8186

@@ -142,7 +147,7 @@ function recurse_var($varname, &$value, $path = '/', $level = 0)
142147

143148
$methods = get_class_methods($value);
144149
foreach ($methods as $method) {
145-
echo "<li><strong>$method</strong> (Function)\n";
150+
echo "<li data-jstree='{\"icon\":\"".BASE_URL."assets/images/function.png\"}'><strong>$method</strong> (Function)\n";
146151
}
147152

148153
echo "</ul></li>\n";
@@ -166,11 +171,16 @@ function recurse_var($varname, &$value, $path = '/', $level = 0)
166171
echo "<li data-jstree='{\"icon\":\"".BASE_URL."assets/images/$icon\"}'><strong>$varname</strong> = " . (is_string($value) ? '"' . htmlentities($value) . '"' : $value) . "</li>\n";
167172
}
168173

169-
// if (!array_key_exists($cache_key,$PARSED_OBJS))
174+
// if (!array_key_exists($cache_key,$PARSED_OBJS)) // this sometimes makes things even more weird
170175
$PARSED_OBJS[$cache_key] = $path;
171176

172177
}
173178

179+
/**
180+
* @param array $_SERVER
181+
* @param bool $use_forwarded_host may need to be set to true if behind a load balancer
182+
* @return string
183+
*/
174184
function url_origin($s, $use_forwarded_host=false)
175185
{
176186
$ssl = (!empty($s['HTTPS']) && $s['HTTPS'] == 'on') ? true:false;
@@ -182,16 +192,27 @@ function url_origin($s, $use_forwarded_host=false)
182192
$host = isset($host) ? $host : $s['SERVER_NAME'] . $port;
183193
return $protocol . '://' . $host;
184194
}
195+
196+
/**
197+
* @param array $_SERVER
198+
* @param bool $use_forwarded_host may need to be set to true if behind a load balancer
199+
* @return string
200+
*/
185201
function full_url($s, $use_forwarded_host=false)
186202
{
187203
return url_origin($s, $use_forwarded_host) . $s['REQUEST_URI'];
188204
}
205+
189206
?>
207+
208+
<p class="top-buffer text-danger"><strong><i class="fa fa-exclamation-triangle"></i> Warning:</strong> This utility may possibly be used to
209+
run untrusted code. Do not leave it installed on an unprotected public server.
210+
<a href="http://php.net/manual/en/function.unserialize.php">More info...</a></p>
190211
</main>
191212

192213
<footer class="footer">
193214
<div class="container">
194-
<div class="text-muted">Created out of spite by <a href="http://verysimple.com/">Jason Hinkle</a> - <a href="credits.php">Credits</a></div>
215+
<div class="text-muted">Created out of spite by <a href="http://verysimple.com/">Jason Hinkle</a></div>
195216
</div>
196217
</footer>
197218

instructions.php

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
8+
<meta name="description" content="">
9+
<meta name="author" content="">
10+
<link rel="icon" href="assets/images/favicon.ico">
11+
<title>PHP Object Browser - Credits</title>
12+
13+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/css/bootstrap.min.css">
14+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css">
15+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jstree/3.1.0/themes/default/style.min.css" />
16+
<link rel="stylesheet" href="assets/css/object-browser.css" />
17+
18+
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
19+
<!--[if lt IE 9]>
20+
<script src="//oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
21+
<script src="//oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
22+
<![endif]-->
23+
</head>
24+
25+
<body>
26+
<nav class="navbar navbar-inverse navbar-fixed-top">
27+
<div class="container">
28+
<div class="navbar-header">
29+
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
30+
<span class="sr-only">Toggle navigation</span>
31+
<span class="icon-bar"></span>
32+
<span class="icon-bar"></span>
33+
<span class="icon-bar"></span>
34+
</button>
35+
<a class="navbar-brand" href="./"><i class="fa fa-cube"></i> PHP Object Browser</a>
36+
</div>
37+
<div id="navbar" class="collapse navbar-collapse">
38+
<ul class="nav navbar-nav">
39+
<li><a href="./">Browser</a></li>
40+
<li class="active"><a href="instructions.php">Instructions</a></li>
41+
<li><a href="credits.php">Credits</a></li>
42+
</ul>
43+
</div><!--/.nav-collapse -->
44+
</div>
45+
</nav>
46+
47+
<main class="container">
48+
49+
<h1>Instructions</h1>
50+
51+
<h3>Usage</h3>
52+
<p>Copy any output from the PHP <code>serialize(...)</code> function.</p>
53+
<p>Paste the serialized code into the object browser text area and submit the form.</p>
54+
55+
<h3>Class Definitions</h3>
56+
<p>In order to view the methods/functions of a class, the class definitions must be included prior to unserialization,
57+
otherwise PHP interprets it as a <code>__PHP_Incomplete_Class</code>.
58+
If you would like to see functions/methods in the browser tree view, you must create a file named <code>includes.php</code> in this directory.
59+
Add all necessary <code>require_once(...)</code> statements to load your class definitions to this file.
60+
The object browser will look for this file and include it prior to unserialization. </p>
61+
62+
<h3>Example serialized code:</h3>
63+
<p>Copy/paste the example code below if you want to simply demo the object browser:</p>
64+
<pre>O:8:"stdClass":2:{s:4:"name";s:16:"This is a string";s:4:"data";a:2:{s:4:"size";i:50;s:5:"color";s:5:"green";}}</pre>
65+
66+
</main>
67+
68+
<footer class="footer">
69+
<div class="container">
70+
<div class="text-muted">Created out of spite by <a href="http://verysimple.com/">Jason Hinkle</a></div>
71+
</div>
72+
</footer>
73+
74+
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
75+
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/js/bootstrap.min.js"></script>
76+
<script src="//cdnjs.cloudflare.com/ajax/libs/jstree/3.1.0/jstree.min.js"></script>
77+
<script>
78+
$(document).ready(function(){
79+
$('#tree-1').jstree();
80+
$('#ajax-loader').hide();
81+
$('#tree-1').show();
82+
});
83+
</script>
84+
</body>
85+
</html>

0 commit comments

Comments
 (0)