-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added examples folder and fixed a few issues in phpLive
- Loading branch information
Showing
30 changed files
with
487 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/nbproject/private/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
require_once '../../phpLive.php'; | ||
$live->list = array(1,2,3,4,5); | ||
echo $live->each(function($k, $v){ | ||
return "$v<br />"; | ||
})->implode(""); | ||
echo "<hr />"; | ||
echo $live->highlight("each.php", HIGHLIGHT_PHP, INPUT_FILE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
require_once '../../phpLive.php'; | ||
$age = mt_rand(0, 3); | ||
echo $live->ifelse($age == 0, function() use ($age){ | ||
return "if statement fired! (\$age = $age)"; | ||
}, $age == 1, function() use ($age){ | ||
return "ifelse statement fired! (\$age = $age)"; | ||
}, function() use ($age){ | ||
return "else fired! (\$age = $age)"; | ||
}); | ||
echo "<hr />"; | ||
echo $live->highlight("ifelse.php", HIGHLIGHT_PHP, INPUT_FILE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
require_once '../../phpLive.php'; | ||
$num = mt_rand(0, 10); | ||
|
||
echo "List: 1, 3, 5, 6<br />"; | ||
|
||
if($live->in($num, 1, 3, 5, 6)){ | ||
echo "$num is in the list"; | ||
}else{ | ||
echo "$num is not in the list"; | ||
} | ||
echo "<hr />"; | ||
echo $live->highlight("in.php", HIGHLIGHT_PHP, INPUT_FILE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
require_once '../../phpLive.php'; | ||
echo "<p>The following will loop 10 times.</p>"; | ||
|
||
$live->loop(function(){ | ||
static $i = 0; | ||
echo "This is : $i<br />"; | ||
$i++; | ||
}, 10); | ||
echo "<hr />"; | ||
echo $live->highlight("loop.php", HIGHLIGHT_PHP, INPUT_FILE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
require_once '../../phpLive.php'; | ||
echo "type 'exit' to quit.\n"; | ||
$live->loop(function() use($live){ | ||
$equation = $live->strOut("type a math equation")->strIn()->toString(); | ||
if(strtolower($equation) == "exit"){ | ||
return true; // End the while loop | ||
} | ||
echo $equation." = "; | ||
eval("echo number_format($equation, 2);"); | ||
echo "\n"; | ||
}); | ||
echo "<hr />"; | ||
echo $live->highlight("listen.php", HIGHLIGHT_PHP, INPUT_FILE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<form action="" method="post"> | ||
<p> | ||
Add: <input type="text" name="date" value="1 day" /> from now. | ||
</p> | ||
<p> | ||
<input type="submit" value="Go!" /> | ||
</p> | ||
</form><?php | ||
if(isset($_POST["date"])) | ||
$range = $_POST["date"]; | ||
else | ||
$range = "1 day"; | ||
require_once "../../phpLive.php"; | ||
echo $live->dateAdd(time(), $range); | ||
?> | ||
<p> </p> | ||
<?php | ||
echo "<hr />"; | ||
echo $live->highlight("date-add.php", HIGHLIGHT_PHP, INPUT_FILE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<form action="" method="post"> | ||
<p> | ||
Subtract: <input type="text" name="date" value="1 day" /> from now. | ||
</p> | ||
<p> | ||
<input type="submit" value="Go!" /> | ||
</p> | ||
</form><?php | ||
if(isset($_POST["date"])) | ||
$range = $_POST["date"]; | ||
else | ||
$range = "1 day"; | ||
require_once "../../phpLive.php"; | ||
echo $live->dateSub(time(), $range); | ||
?> | ||
<p> </p> | ||
<?php | ||
echo "<hr />"; | ||
echo $live->highlight("date-sub.php", HIGHLIGHT_PHP, INPUT_FILE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<form action="" method="post"> | ||
<p> | ||
Date 1: <input type="text" name="date1" value="<?php echo date("Y-m-d H:i:s"); ?>" /><br /> | ||
Date 2: <input type="text" name="date2" value="<?php echo date("Y-m-d H:i:s"); ?>" /> | ||
</p> | ||
<p> | ||
<input type="submit" value="Go!" /> | ||
</p> | ||
</form><?php | ||
require_once "../../phpLive.php"; | ||
echo $live->datediff($_POST["date1"], $_POST["date2"]); | ||
?> | ||
<p> </p> | ||
<?php | ||
echo "<hr />"; | ||
echo $live->highlight("datediff.php", HIGHLIGHT_PHP, INPUT_FILE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
require_once '../../phpLive.php'; | ||
echo <<<OPT | ||
<form action="" method="post"> | ||
<p>First:<br /><input type="text" name="first" /></p> | ||
<p>Last:<br /><input type="text" name="last" /></p> | ||
<p>Email:<br /><input type="text" name="email" /></p> | ||
<p><input type="submit" value="Test for empties!" /></p> | ||
</form> | ||
OPT; | ||
if($live->post()){ | ||
if($live->empties($_POST["first"], $_POST["last"], $_POST["email"])){ | ||
echo "The following were empty:<br />"; | ||
print_r($live->list); | ||
}else{ | ||
echo "There are no empty values!"; | ||
} | ||
} | ||
echo "<hr />"; | ||
echo $live->highlight("empties.php", HIGHLIGHT_PHP, INPUT_FILE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
require_once '../../phpLive.php'; | ||
echo <<<FORM | ||
<form method="post"> | ||
Which animal do you prefer?<br /> | ||
<input type="radio" name="animal" value="dog" /> Dog<br /> | ||
<input type="radio" name="animal" value="cat" /> Cat<br /> | ||
<input type="submit" value="What Sound?" /> | ||
</form> | ||
FORM; | ||
|
||
/** | ||
* phpLive::favoriteAnimal() | ||
* phpLive::animalNoise() | ||
* | ||
* The two methods can be found in extensions/example.php | ||
*/ | ||
|
||
if($live->post()){ | ||
echo <<<ANIMAL | ||
{$live->post("animal")->favoriteAnimal()} | ||
{$live->animalNoise()} | ||
ANIMAL; | ||
} | ||
|
||
echo "<hr />"; | ||
echo $live->highlight("extend.php", HIGHLIGHT_PHP, INPUT_FILE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
require_once "../../phpLive.php"; | ||
echo "<h3>Html File</h3>"; | ||
echo "<pre>".$live->highlight("test_html.html", HIGHLIGHT_HTML, INPUT_FILE)->tabToSp()."</pre>"; | ||
echo "<hr />"; | ||
echo "<h3>Xml File</h3>"; | ||
echo "<pre>".$live->highlight("test_xml.xml", HIGHLIGHT_HTML, INPUT_FILE)->tabToSp()."</pre>"; | ||
echo "<hr />"; | ||
echo "<h3>CSS File</h3>"; | ||
echo "<pre>".$live->highlight("test_css.css", HIGHLIGHT_CSS, INPUT_FILE)->tabToSp()."</pre>"; | ||
|
||
echo "<hr />"; | ||
echo $live->highlight("highlight.php", HIGHLIGHT_PHP, INPUT_FILE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
require_once "../../phpLive.php"; | ||
echo $live->inetAToN("10.0.5.9"); | ||
echo "<br />"; | ||
echo $live->inetNToA(167773449); | ||
echo "<hr />"; | ||
|
||
echo $live->highlight("inet-aton.php", HIGHLIGHT_PHP, INPUT_FILE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
require_once '../../phpLive.php'; | ||
echo "<p style='color: red;'>The below output is html from a random page (see code at the bottom of this page)</p>"; | ||
echo "<hr />"; | ||
echo htmlentities($live->random("http://php.net", "http://phplive.org", "http://phpsnips.com")->getHttp()); | ||
|
||
echo "<hr />"; | ||
echo $live->highlight("random.php", HIGHLIGHT_PHP, INPUT_FILE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
body{ | ||
font-size: 12px; | ||
color: #ffffff; | ||
background-color: #000000; | ||
background-image: url("/images/test.png"); | ||
} | ||
|
||
#testID{color: green;} | ||
/* | ||
.display{ | ||
display: block; | ||
} | ||
*/ | ||
.display-none{ | ||
display: none; | ||
} | ||
|
||
a.link{ | ||
color: red; | ||
text-decoration: none; | ||
} | ||
|
||
a.link:hover{ | ||
text-decoration: underline; | ||
} | ||
|
||
.pa{ | ||
color: red; | ||
} | ||
a{ | ||
color: #ff0000; | ||
} | ||
|
||
*{ | ||
font-size: 12px; | ||
} | ||
|
||
div>a{ | ||
padding: 10px; | ||
} | ||
|
||
[lang=en]{ | ||
color: red; | ||
} | ||
|
||
p:lang(it){ | ||
color: blue; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!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" xml:lang="en"> | ||
<head> | ||
<title>HTML Highlight Example</title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||
<style type="text/css"> | ||
body{ | ||
background-color: #ffffff; | ||
font-size: 20px; | ||
color: red; | ||
} | ||
h1, h2{ | ||
border-bottom: solid 1px #aaaaaa; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<!-- | ||
<p>Sed vitae tristique ipsum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Mauris sit amet arcu eu turpis sollicitudin vestibulum. In hac habitasse platea dictumst. Ut pulvinar blandit mi, non condimentum sem tincidunt ut. Mauris auctor risus sed nisl consectetur pulvinar. Praesent vel risus sit amet tellus bibendum pretium eget at orci. Cras pharetra nisl nec leo laoreet in auctor eros rutrum. Donec ultricies justo et est tristique aliquam. Sed in odio ut dui ullamcorper dignissim ut egestas felis.</p> | ||
--> | ||
<style type="text/css"> | ||
p > a{ | ||
background-color: #000000; | ||
color: #ffffff; | ||
font-size: 20px; | ||
color: red; | ||
} | ||
</style> | ||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sollicitudin aliquet nulla eget pulvinar. Ut a nisl vel est convallis feugiat a vel justo. Donec vel justo in tellus adipiscing facilisis. Donec lacus urna, cursus eget mattis ut, rhoncus vel orci. Morbi felis diam, lobortis id dictum convallis, congue et erat. Curabitur a hendrerit elit. Sed quis neque lorem. Pellentesque volutpat eros at sapien pretium sed aliquet orci varius. Suspendisse arcu enim, mattis a eleifend quis, imperdiet vel felis. Morbi lacinia elementum egestas. Sed fringilla libero a leo lacinia non egestas ante pellentesque. In ullamcorper varius tempor.</p> | ||
<p>Sed vitae tristique ipsum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Mauris sit amet arcu eu turpis sollicitudin vestibulum. In hac habitasse platea dictumst. Ut pulvinar blandit mi, non condimentum sem tincidunt ut. Mauris auctor risus sed nisl consectetur pulvinar. Praesent vel risus sit amet tellus bibendum pretium eget at orci. Cras pharetra nisl nec leo laoreet in auctor eros rutrum. Donec ultricies justo et est tristique aliquam. Sed in odio ut dui ullamcorper dignissim ut egestas felis.</p> | ||
<p>Quisque sit amet diam justo, nec sagittis elit. Sed eu nibh a ante vehicula mollis. Pellentesque eu ligula eget nunc euismod placerat sit amet eu velit. Fusce laoreet, risus non ullamcorper mollis, mi enim congue ipsum, consectetur pellentesque augue erat a nisl. Morbi a purus ut lectus ornare posuere. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam varius, sem sed sollicitudin condimentum, tortor erat cursus elit, vitae ornare sem ante id justo. Praesent at tortor leo, ac tempus tellus. Quisque vitae sem neque. Suspendisse vitae erat ligula. Sed eu mauris id dui feugiat faucibus nec ac eros. Nam sollicitudin, ante condimentum pellentesque commodo, neque risus congue quam, sed sodales erat diam ac nulla. Ut mattis magna enim. Quisque tincidunt nisi at sapien scelerisque pretium. Aliquam feugiat interdum dolor sed ullamcorper.</p> | ||
<p>Nulla vehicula tristique nulla, ac tincidunt nunc condimentum quis. Fusce nunc arcu, tincidunt et tempus et, volutpat et nunc. Nunc iaculis eros eget risus egestas interdum consectetur ipsum interdum. Donec sit amet nunc vitae turpis condimentum scelerisque. Suspendisse potenti. Suspendisse potenti. Sed ante quam, consequat a mattis ac, dictum eu dolor. Donec elit neque, aliquam vel blandit vel, cursus non velit. Praesent tortor nunc, viverra in luctus tempus, tincidunt in nulla. Etiam consectetur risus sit amet felis porta lobortis ac blandit lacus. Vestibulum iaculis laoreet vulputate.</p> | ||
<p>Aliquam venenatis, odio a convallis egestas, odio enim semper tortor, eget lacinia nunc lectus quis elit. Etiam interdum nulla et risus scelerisque ut vehicula magna semper. Mauris urna massa, tempus eu ultrices vel, venenatis at lectus. Pellentesque auctor interdum lorem, hendrerit malesuada sapien ultricies eget. Sed mattis, leo sit amet iaculis rutrum, quam nunc fringilla est, id rhoncus odio tortor eget mauris. Suspendisse malesuada accumsan laoreet. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vestibulum adipiscing lacus vel enim pretium adipiscing ultrices erat blandit. In porttitor nulla ut eros pellentesque malesuada. Aliquam aliquet lacinia scelerisque. Nullam fringilla volutpat sem.</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<root> | ||
<!-- | ||
People who are 25 years old | ||
--> | ||
<names age="25"> | ||
<name>Ryan</name> | ||
<name>Bill</name> | ||
<name>Bob</name> | ||
</names> | ||
<!-- People who are 45 years old --> | ||
<names age="45"> | ||
<name>Roy</name> | ||
<name>Jill</name> | ||
<name>Jimmy</name> | ||
</names> | ||
</root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
require_once '../../phpLive.php'; | ||
$download = (bool)$live->get("d")->toString(); | ||
if($download){ | ||
/** | ||
* Array key is the location on the server | ||
* Array value is the location in the zip | ||
* | ||
* If an array key is not given it will save in the root of the zip and look | ||
* for it with the given server location. If the file is not found it will be | ||
* added as a directory in the zip. | ||
*/ | ||
$files = array( | ||
/** | ||
* creates a folder ".." and a "construct" folder in it and puts "each.php" there | ||
* add a value to this to save it with a better path name | ||
*/ | ||
"../construct/each.php", | ||
"inet-aton.php", | ||
"folder A", | ||
"random.php" => "folder A/random.php" | ||
); | ||
$live->zip($files)->download(PHP_TMPFILE, "download.zip"); | ||
exit; | ||
}else{ | ||
echo "<p><a href='?d=1'>Download Zip File</a></p>"; | ||
echo "<hr />"; | ||
echo $live->highlight("zip.php", HIGHLIGHT_PHP, INPUT_FILE); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
require_once "../../phpLive.php"; | ||
echo $live->read("../../phpLive.php")->regCount("public function"); | ||
echo "<hr />"; | ||
echo $live->highlight("regCount.php", HIGHLIGHT_PHP, INPUT_FILE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<style type="text/css"> | ||
p.good{color:green;font-weight:bold;} | ||
p.bad{color:red;font-weight:bold;} | ||
</style><?php | ||
require_once "../../phpLive.php"; | ||
if($live->get()){ | ||
if($live->get("name")->blank()){ | ||
echo "<p class='bad'>Name is blank!</p>"; | ||
}else{ | ||
echo "<p class='good'>Name is not blank!</p>"; | ||
} | ||
} | ||
echo <<<FORM | ||
<form action="" method="get"> | ||
<table> | ||
<tr><td>Name:</td><td><textarea type="text" name="name">{$live->get("name")}</textarea></td></tr> | ||
<tr><td><input type="submit" value="Is Empty?"></td></tr> | ||
</table> | ||
</form> | ||
FORM; | ||
?> | ||
<p> | ||
<b>Note:</b> $live->blank() is <u>NOT</u> the same as empty(). A space is not considered an empty string when using empty().<br /> | ||
<b>Note:</b> Using $live->blank() a space is considered an empty string, so are tabs, newlines and carriage returns.<br /> | ||
<b>Note:</b> Use $live->blanks() to check for a list of empty strings. | ||
</p> | ||
<hr /> | ||
<?php | ||
echo $live->highlight("blank.php", HIGHLIGHT_PHP, INPUT_FILE); | ||
?> |
Oops, something went wrong.