예제 #1
0
 /**
  * Test alphanum sanitization.
  */
 public function test_sanitize_alphanum()
 {
     $dirty = ['1a2B3c', '()&@(*&(*$', '123$%%aBc', '', true, false, null, [], new \stdClass(), 0, 1, 2];
     $clean = ['1a2B3c', '', '123aBc', '', '', '', '', '', '', 0, 1, 2];
     foreach ($dirty as $i => $val) {
         $expected = $clean[$i];
         $actual = \pdyn\datatype\Sanitizer::alphanum($val);
         $this->assertEquals($expected, $actual);
     }
 }
예제 #2
0
파일: FileCache.php 프로젝트: pdyn/cache
 /**
  * Get the filename for the cache for a given type and key.
  *
  * @param string $type The cache type - use this like a category for the data.
  * @param string $key The cache key - a key to identify this information within the category $type.
  * @return string The full filename.
  */
 public function get_filename($type, $key)
 {
     if (!isset($this->keycache[$key])) {
         $this->keycache[$key] = md5($key);
     }
     $type = \pdyn\datatype\Sanitizer::alphanum($type);
     return $this->cachedir . '/' . $type . '/' . $this->keycache[$key];
 }