<?php
function get_images($file,$url){
$regs=array();
$images=array();
preg_match_all('/<s?img(.*?)>/i',$file,$regs);
foreach($regs[0] as $key=>$value){
$items = explode('=',$value);
$count = count($items);
for($i=0;$i<$count;$i++){
$item = str_replace(strrchr($items[$i+1],' '),'',$items[$i+1]);
$item = trim(preg_replace('/("|')/','',$item));
if(preg_match('/src/i',$items[$i])){
if(trim($item)!=''){
if(preg_match('/((.*)(.gif|.jpeg|.jpg|.png))(.*)/',$item,$reg)){
$images[$key]['src']=find_true_path($url,$reg[1]);
}
}else{
continue;
}
}
elseif(preg_match('/alt/i',$items[$i])){
if($item!=''){
if(isset($images[$key]['src'])){
$images[$key]['alt']=$item;
}else{
continue;
}
}else{
continue;
}
}
elseif(preg_match('/title/i',$items[$i])){
if($item!=''){
if(isset($images[$key]['src'])){
$images[$key]['title']=preg_replace('/["']/','',$item);
}else{
continue;
}
}else{
continue;
}
}else{
continue;
}
}
}
return($images);
}
function find_true_path($url,$image_location){
if(preg_match('/http/',$image_location)){
return($image_location);
}else{
$true_location='';
if(substr($image_location,0,2)=='./'){
$image_location=substr($image_location,2);
}
elseif(substr($image_location,0,1)=='/'){
$image_location=substr($image_location,1);
}else{
$image_location=$image_location;
}
$back_folder_count = substr_count($image_location,'../');
$url = substr($url,0,strrpos($url,'/'));
for($i=0;$i<$back_folder_count;$i++){
if(strrpos($url,'/')==strlen($url)-1){
$url = substr($url,0,-1);
$url = substr($url,0,strrpos($url,'/'));
}else{
$url = substr($url,0,strrpos($url,'/'));
}
}
if(substr($url,-1)!='/'){
$url = $url.'/';
}
$image_location = preg_replace('/(../)/','',$image_location);
$true_location = $url.$image_location;
return($true_location);
}
}
?>
Tag Archive for remove
Remove images from html
Strip(i.e. remove) special character(s)
/* Strip(remove) special character(s) from a string. Parameters -1-: String to process -2-: Special character to strip Note: If second parameter is null then the following list is used: <tab>, <single quote>, <double quote>, <>, <|>, <`>, <~>, <^> */ FUNCTION strip_spc_character ( in_string IN varchar2, in_chars IN varchar2 DEFAULT null ) return varchar2 is tab char( 1 ) := chr(9); double_quote char( 1 ) := chr(34); single_quote char( 1 ) := chr(39); mask varchar2( 80 ) := '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; v_special_chars varchar2( 80 ) := '`~^|'||double_quote||single_quote||tab; begin if in_chars is not null then v_special_chars := in_chars; end if; return translate( in_string, mask || v_special_chars, mask ); exception when others then return in_string; end strip_spc_character;
remove missing files with SVN
svn rm $( svn status | sed -e '/^!/!d' -e 's/^!//' )
Remove All childNodes
var holder = document.getElementById("whateverDiv");//the holder div
while(holder.hasChildNodes()){
holder.removeChild(holder.lastChild);
}
Strip HTML tags from string
function stripHtml(s) {
return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/t/g, ' ').replace(/n/g, '<br />');
}
undohtml.css – Tantek’s Original (Removes Browser Default Style)
/* undohtml.css */
/* (CC) 2004 Tantek Celik. Some Rights Reserved. */
/* <a href="http://creativecommons.org/licenses/by/2.0" >http://creativecommons.org/licenses/by/2.0</a> */
/* This style sheet is licensed under a Creative Commons License. */
/* <a href="http://www.tantek.com/log/2004/undohtml.css" >http://www.tantek.com/log/2004/undohtml.css</a> */
/* Purpose: undo some of the default styling of common (X)HTML browsers */
/* link underlines tend to make hypertext less readable,
because underlines obscure the shapes of the lower halves of words */
:link,:visited { text-decoration:none }
/* no list-markers by default, since lists are used more often for semantics */
ul,ol { list-style:none }
/* avoid browser default inconsistent heading font-sizes */
/* and pre/code too */
h1,h2,h3,h4,h5,h6,pre,code { font-size:1em; }
/* remove the inconsistent (among browsers) default ul,ol padding or margin */
/* the default spacing on headings does not match nor align with
normal interline spacing at all, so let's get rid of it. */
/* zero out the spacing around pre, form, body, html, p, blockquote as well */
/* form elements are oddly inconsistent, and not quite CSS emulatable. */
/* nonetheless strip their margin and padding as well */
ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,body,html,p,blockquote,fieldset,input
{ margin:0; padding:0 }
/* whoever thought blue linked image borders were a good idea? */
a img,:link img,:visited img { border:none }
/* de-italicize address */
address { font-style:normal }
/* more varnish stripping as necessary... */
Devuelve el Querystring sin un parametro indicado
function querystringWithoutParameter($parametro){
return preg_replace('/[&?]+'.$parametro.'=[^&]*/','',$_SERVER['QUERY_STRING']);
}