Ejemplo n.º 1
0
/**
 * second level of scoping
 *
 */
function testScoping2()
{
    $cage_POST = Inspekt::makePostCage();
    echo "<pre>In " . __FUNCTION__ . "(): ";
    var_dump($cage_POST->testAlnum('/funky,_+=_\\|;:!@#$%^&*~time/0/0/`~foo,.+=_\\|;:!@#$%^&*~-bar'));
    echo "</pre>\n";
    echo "<pre>POST is not accessible here: ";
    var_dump($_POST);
    echo "</pre>\n";
}
Ejemplo n.º 2
0
/**
 * a wrapper to retrieve input from either the get or post Inspekt cages
 *
 * @param string $key the key you're trying to retrieve
 * @param string $accessor the name of the accessor method to use
 * @return mixed  null if key does not exist
 * @author Ed Finkler
 */
function getInputGP($key, $accessor)
{
    /*
        this returns the singleton
    */
    $sc = Inspekt::makeSuperCage();
    if ($sc->get->keyExists($key)) {
        return $sc->get->{$accessor}($key);
    } elseif ($sc->post->keyExists($key)) {
        return $sc->post->{$accessor}($key);
    } else {
        return null;
    }
}
Ejemplo n.º 3
0
<?php

/**
 * Demonstration of:
 * - use of static filter methods on arrays
 * - creating a cage on an arbitrary array
 * - Accessing cage param via array syntax
 */
require_once dirname(__FILE__) . "/../vendor/autoload.php";
use Inspekt\Inspekt;
$_GET['locale'] = "en_US";
$_GET['new'] = 1;
$_GET['time'] = 1246233204.5486;
$_GET['id'] = 7444632820;
$_GET['key'] = "2.Hhun0mQ4KF1BfJ_WfeBB3Q__.86400.1246320000-714446282";
$_GET['ss'] = "un4SUm022i5sZ5iIZeNYWQ__";
$_GET['somestuff'] = "i, would, like, some, milk, and__cookies--please!";
$getCage = Inspekt::makeGetCage();
echo "\n<pre>All the cage params:\n\n";
foreach ($getCage as $key => $value) {
    var_dump($key);
    var_dump($value);
    var_dump($getCage->getAlpha($key));
    echo "\n";
}
echo 'Accessing cage param via array syntax "$getCage[\'locale\']" :: ' . Inspekt::getAlnum($getCage['locale']);
echo "\n</pre>\n";
Ejemplo n.º 4
0
 /**
  * Escapes the value given with pg_escape_bytea
  *
  * @param mixed $value
  * @param resource $conn the postgresql connection. If none is given, it will use the last link opened,
  *        per behavior of pg_escape_bytea
  * @return mixed
  *
  * @link http://php.net/manual/en/function.pg-escape-bytea.php
  */
 public static function escPgSQLBytea($value, $conn = null)
 {
     if (Inspekt::isArrayOrArrayObject($value)) {
         return Inspekt::walkArray($value, 'escPgSQL');
     } else {
         //might also check is_resource if pg_connection_status is too much
         if (isset($conn) && pg_connection_status($conn) === PGSQL_CONNECTION_OK) {
             return pg_escape_bytea($conn, $value);
         } else {
             return pg_escape_bytea($value);
         }
     }
 }
Ejemplo n.º 5
0
<?php

require_once dirname(__FILE__) . "/../vendor/autoload.php";
use Inspekt\Inspekt;
$superCage = Inspekt::makeSuperCage();
echo "<pre>";
var_dump($superCage);
echo "</pre>\n";
echo 'Digits:' . $superCage->server->getDigits('SERVER_SOFTWARE') . '<p/>';
echo 'Alpha:' . $superCage->server->getAlpha('SERVER_SOFTWARE') . '<p/>';
echo 'Alnum:' . $superCage->server->getAlnum('SERVER_SOFTWARE') . '<p/>';
echo 'Raw:' . $superCage->server->getRaw('SERVER_SOFTWARE') . '<p/>';
Ejemplo n.º 6
0
$newd = Inspekt::noTags($d);
echo "<pre>";
var_dump($newd);
echo "</pre>\n";
?>


<h2>Inspekt::noTagsOrSpecial($d)</h2>
<?php 
$newd = Inspekt::noTagsOrSpecial($d);
echo "<pre>";
var_dump($newd);
echo "</pre>\n";
?>


<h2>Inspekt::getDigits($d)</h2>
<?php 
$newd = Inspekt::getDigits($d);
echo "<pre>";
var_dump($newd);
echo "</pre>\n";
?>


<h2>Inspekt::getROT13($d)</h2>
<?php 
$newd = Inspekt::getROT13($d);
echo "<pre>";
var_dump($newd);
echo "</pre>\n";
Ejemplo n.º 7
0
<?php

/**
 * Demonstration of:
 * - helper "make*Cage()" methods to create input cage from superglobal
 * - cleanup of HTTP_*_VARS
 * - cage filter methods
 * - "Array Query" method of accessing deep keys in multidim arrays
 */
require_once dirname(__FILE__) . "/../vendor/autoload.php";
use Inspekt\Inspekt;
$serverCage = Inspekt::makeServerCage();
echo "<pre>";
var_dump($serverCage);
echo "</pre>\n";
echo 'Digits:' . $serverCage->getDigits('SERVER_SOFTWARE') . '<p/>';
echo 'Alpha:' . $serverCage->getAlpha('SERVER_SOFTWARE') . '<p/>';
echo 'Alnum:' . $serverCage->getAlnum('SERVER_SOFTWARE') . '<p/>';
echo 'Raw:' . $serverCage->getRaw('SERVER_SOFTWARE') . '<p/>';
echo '<pre>$_SERVER:';
var_dump($_SERVER);
echo "</pre>\n";
echo '<pre>HTTP_SERVER_VARS:';
var_dump($HTTP_SERVER_VARS);
echo "</pre>\n";
var_dump($serverCage->getAlnum('/argv/0'));
Ejemplo n.º 8
0
 /**
  *
  */
 public function testNoPath()
 {
     $input = './../../../../../../../../../etc/passwd';
     $expect = 'passwd';
     $this->assertSame($expect, Inspekt::noPath($input));
 }
Ejemplo n.º 9
0
<?php

require_once dirname(__FILE__) . "/../vendor/autoload.php";
use Inspekt\Inspekt;
$_POST['userid'] = "\\'; DESC users; --";
$_POST['email'] = '*****@*****.**';
$_POST['text'] = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus nisl dolor, pulvinar id, pharetra a, egestas nec, ante. Duis scelerisque eleifend metus. Sed non odio id odio varius rutrum. Pellentesque congue commodo lacus. In semper pede lacinia felis. Morbi mollis molestie lorem. Morbi suscipit libero. Quisque ut erat sit amet elit aliquam nonummy. Donec tortor. Aliquam gravida ullamcorper pede. Praesent eros. Sed fringilla ligula sed odio pharetra imperdiet. Integer aliquet quam vitae nibh. Nam pretium, neque non congue vulputate, odio odio vehicula augue, sit amet gravida pede massa ac lectus. Curabitur a libero vitae dui sagittis aliquet. Ut suscipit. Curabitur accumsan sem a urna. Ut elit pede, vulputate sed, feugiat quis, congue sed, lacus.';
$mysql_conn = mysql_connect('localhost', 'inspekt_test', 'ewp-odd-ia');
$sc = Inspekt::makeSuperCage();
echo $sc->post->escMySQL('userid', $mysql_conn);
Ejemplo n.º 10
0
    <title>formtest</title>

</head>

<body>
<form action="formtest.php" method="POST">
    <h3>Enter 5 email addresses</h3>
    <input type="text" name="email_addresses[group1][a]" value="*****@*****.**"/><br/>
    <input type="text" name="email_addresses[group1][b]" value="*****@*****.**"/><br/>
    <input type="text" name="email_addresses[group1][c]" value="*****@*****.**"/><br/>
    <input type="text" name="email_addresses[group2][a]" value="*****@*****.**"/><br/>
    <input type="text" name="email_addresses[group2][b]" value="*****@*****.**"/><br/>
    <input type="text" name="email_addresses[group3][a]" value="*****@*****.**"/><br/>
    <input type="text" name="email_addresses[group3][b]" value="*****@*****.**"/><br/>

    <input type="submit" name="submit" value="Go!" id="submit"/>
</form>

<?php 
$input = Inspekt::makeSuperCage();
$email = $input->post->testEmail('/email_addresses/group3/a');
if ($email) {
    echo $email;
} else {
    echo "invalid address";
}
?>

</body>
</html>
Ejemplo n.º 11
0
 /**
  *
  */
 public function testTestAlnum3()
 {
     $_POST = array();
     $_POST['b'] = '0';
     $cage_POST = Inspekt::makePostCage();
     $result = $cage_POST->testLessThan('b', 25);
     $this->assertSame('0', $result);
 }
Ejemplo n.º 12
0
<?php

require_once dirname(__FILE__) . "/../vendor/autoload.php";
use Inspekt\Inspekt;
$URIs = array('//lessthan', 'ftp://*****:*****@123.444.999.12/', 'http://spinaltap.micro.umn.edu/00/Weather/California/Los%lngeles', 'http://funkatron.com/////////12341241', 'http://funkatron.com:12', 'http://funkatron.com:8000/#foo', 'https://funkatron.com', 'https://funkatron.com:42/funky.php?foo[]=bar', 'http://www.w3.org/2001/XMLSchema');
foreach ($URIs as $uri) {
    echo 'Testing ' . $uri . '<br/>';
    $rs = Inspekt::isUri($uri);
    echo "<pre>";
    var_dump($rs);
    echo "</pre>\n";
    echo "<hr>";
}