Example #1
0
 public function testGetDomainFromImage()
 {
     $values = array(array('http://i.imgur.com/xyzu.png', 'i.imgur.com'), array('http://imgur.com/xyzu.png', 'imgur.com'), array('http://www.imgur.es/xyzu.png', 'www.imgur.es'), array('http://fully.known.imgur.es', ''), array('http://imgur.es/hyz.gif', 'imgur.es'), array('http://imgur.jpg', false), array('http://www.imgur.', false));
     foreach ($values as $val) {
         $v = getDomainFromImage($val[0]);
         $this->assertEquals($v, $val[1]);
         var_dump($v);
     }
 }
Example #2
0
function text_to_html_callback($matches) {
	global $globals;

	switch ($matches[2][0]) {
		case '_':
			return $matches[1].'<em>'.substr($matches[2], 1, -1).'</em>';
		case '*':
			return $matches[1].'<strong>'.substr($matches[2], 1, -1).'</strong>';
		case '-':
			return $matches[1].'<strike>'.substr($matches[2], 1, -1).'</strike>';
		case '#';
			if ($globals['hashtype']) {
				return $matches[1].'<a href="'.$globals['base_url'].'search.php?w='.$globals['hashtype'].'&amp;q=%23'.substr($matches[2], 1).'&amp;o=date">#'.substr($matches[2], 1).'</a>';
			}
		case 'h':
      $t = strtolower(substr($matches[2],-3,3));
      if ( $t == "gif" || $t == "jpg" || $t == "png") {
        $d = getDomainFromImage(htmlentities($matches[2]));
        return '<div class="comment-container">'
		.'<div  >'
		.'<a href="'.htmlentities($matches[2]).'"><img src="'.htmlentities($matches[2]).'"  class="comment-image" /></a>'
		.'</div>'
    .'<div class="comment-foot" >'
		.$d
		.'</div>'
	.'</div>';
      } else {
        return $matches[1].preg_replace('/(https*:\/\/)(www\.){0,1}([^ \t\n\r\]\&]{5,70})([^ \t\n\r]*)([^ :.\t,\n\r\(\"\'\]\?])(.*)/u', '<a href="$1$2$3$4$5" title="$1$2$3$4$5" rel="nofollow">$3$5</a>$6', $matches[2]);
      }
		
	}
	return $matches[1].$matches[2];
}