Version: 1.1
Type: Class
Category: HTML
License: WebSite Only
Description: Parser for Inserting HTML TAGS
Adding Font Style,
Font Weight,Hyperlink
Can Add more Tags
<?php class ChangeStyle { var $tokstr; var $globalid; var $globalvalue; var $fontarray=array(); var $hyparray=array(); var $Imgarray=array(); var $hypatttype=array(); var $staticcount; var $hypcount; var $hypattcount; var $Imgcount; var $mFlag="false"; var $mLeveltrace; var $samplestr; var $fpp1; var $mhdrvalue; var $mftrvalue; var $mMainfilename; function ChangeStyle($filename) { $this->mMainfilename=$filename; //echo $this->mMainfilename; } function ConcatString($regionname,$globalid,$globalvalue) { $this->globalid=$globalid; $this->globalvalue=$globalvalue; $this->tokstr=" "; $fd = fopen($this->mMainfilename, "r+"); $contents = fread($fd,filesize($this->mMainfilename)); fclose($fd); $parser = xml_parser_create(); xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0); xml_parse_into_struct($parser,$contents,&$vals,&$index); xml_parser_free($parser); $this->staticcount=1; $this->hypcount=1; $this->Imgcount=1; $this->hypattcount=1; for ($i=0;$i<count($vals);$i++) { // print_r($vals[$i]); $this->seektag(strtolower($vals[$i][tag]),$vals[$i][type],$vals[$i][value],$vals[$i]["attributes"],$regionname,$vals[$i][level]); } $expstr=array(); $expstr=explode(" ",stripslashes(stripcslashes(trim($this->tokstr)))); $expstrval=" "; for($h=0;$h<count($expstr);$h++) { if($expstr[$h]!='') { $expstrval=$expstrval." ".$expstr[$h]; } } return trim($expstrval); } function seektag($tagname,$tagtype,$tagvalue,$attname,$regionname,$leveltrace) { switch ($tagtype) { case "open": if($tagname=='b' && $this->mLeveltrace<$leveltrace && $this->mFlag=="true") { $this->tokstr= $this->tokstr."<b>".$tagvalue; } elseif($tagname=='u' && $this->mLeveltrace<$leveltrace && $this->mFlag=="true") { $this->tokstr= $this->tokstr."<u>".$tagvalue; } elseif($tagname=='font' && $this->mLeveltrace<$leveltrace && $this->mFlag=="true") { $attrstr; if($attname!='') { $strval=array_keys($attname); for($j=0;$j<count($attname);$j++) { $rr=$attname[$strval[$j]]; $attrstr=$attrstr." ".$strval[$j]."='".$rr."'"; } if($this->globalid=='size'|| $this->globalid=='style' || $this->globalid=='link' || $this->globalid=='imgtxt' && $this->globalvalue!='') { $this->fontarray[$this->staticcount]=$attrstr; // echo $this->fontarray[$this->staticcount]; $this->staticcount=$this->staticcount+1; } $this->tokstr=$this->tokstr."<font>".$tagvalue; } else { $this->tokstr=$this->tokstr."<font>".$tagvalue; } } elseif($tagname=='a' && $this->mLeveltrace<$leveltrace && $this->mFlag=="true") { $attrstr; if($attname!='') { $strval=array_keys($attname); for($j=0;$j<count($attname);$j++) { //strlen(substr(strrchr ($rr, "/"),1)) $rr=$attname[$strval[$j]]; $attrstr=$attrstr." ".$strval[$j]."='".$rr."'"; $this->hypatttype[$this->hypattcount]=substr($rr,0,strlen($rr)-strlen(substr(strrchr ($rr, "/"),1))); $this->hypattcount=$this->hypattcount+1; } if($this->globalid=='size'|| $this->globalid=='style' || $this->globalid=='link' || $this->globalid=='imgtxt' && $this->globalvalue!='') { // echo "ope hello"; $this->hyparray[$this->hypcount]=$attrstr; $this->hypcount=$this->hypcount+1; } $this->tokstr=$this->tokstr."<a>".$tagvalue; } else { $this->tokstr=$this->tokstr."<a>".$tagvalue; } } elseif($tagname=='img' && $this->mLeveltrace<$leveltrace && $this->mFlag=="true") { $attrstr; if($attname!='') { $strval=array_keys($attname); for($j=0;$j<count($attname);$j++) { $rr=$attname[$strval[$j]]; $attrstr=$attrstr." ".$strval[$j]."='".$rr."'"; } if($this->globalid=='size'|| $this->globalid=='style' || $this->globalid=='link' || $this->globalid=='imgtxt' && $this->globalvalue!='') { $this->Imgarray[$this->Imgcount]=$attrstr; // echo $this->Imgarray[$this->hypcount]; $this->Imgcount=$this->Imgcount+1; } $this->tokstr=$this->tokstr."<img>".$tagvalue."</img>"; } else { // echo "hello2"; $this->tokstr=$this->tokstr."<img>".$tagvalue."</img>"; } } elseif($tagname=='text' && $attname["name"]==$regionname ) { $this->toktype= $tagtype; $this->tokstr= $this->tokstr.$tagvalue; $this->mLeveltrace=$leveltrace; $this->mFlag="true"; } elseif($tagname=='i' && $this->mLeveltrace<$leveltrace && $this->mFlag=="true") { $this->tokstr= $this->tokstr."<i>".$tagvalue; } break; case "close": if($tagname=='b'&& $this->mLeveltrace<$leveltrace && $this->mFlag=="true") { $this->tokstr= $this->tokstr."</b>"; } elseif($tagname=='text') { $this->mFlag="false"; } elseif($tagname=='font' && $this->mLeveltrace<$leveltrace && $this->mFlag=="true") { $this->tokstr= $this->tokstr."</font>"; } elseif($tagname=='img' && $this->mLeveltrace<$leveltrace && $this->mFlag=="true") { $this->tokstr= $this->tokstr."</img>"; } elseif($tagname=='a' && $this->mLeveltrace<$leveltrace && $this->mFlag=="true") { $this->tokstr= $this->tokstr."</a>"; } elseif($tagname=='i'&& $this->mLeveltrace<$leveltrace && $this->mFlag=="true") { $this->tokstr= $this->tokstr."</i>"; } elseif($tagname=='u'&& $this->mLeveltrace<$leveltrace && $this->mFlag=="true") { $this->tokstr= $this->tokstr."</u>"; } break; case "complete": if($tagname=='text' && $attname["name"]==$regionname) { $this->toktype= $tagtype; $this->tokstr= $this->tokstr.$tagvalue; } elseif($tagname=='i'&& $this->mLeveltrace<$leveltrace && $this->mFlag=="true") { $this->tokstr= $this->tokstr."<i>".$tagvalue."</i>"; } elseif($tagname=='u'&& $this->mLeveltrace<$leveltrace && $this->mFlag=="true") { $this->tokstr= $this->tokstr."<u>".$tagvalue."</u>"; } elseif($tagname=='b' && $this->mLeveltrace<$leveltrace && $this->mFlag=="true") { $this->tokstr= $this->tokstr."<b>".$tagvalue."</b>"; } elseif($tagname=='font' && $this->mLeveltrace<$leveltrace && $this->mFlag=="true") { $attrstr; if($attname!='') { $strval=array_keys($attname); for($j=0;$j<count($attname);$j++) { $rr=$attname[$strval[$j]]; $attrstr=$attrstr." ".$strval[$j]."='".$rr."'"; } if($this->globalid=='size'|| $this->globalid=='style' || $this->globalid=='link' || $this->globalid=='imgtxt' && $this->globalvalue!='') { $this->fontarray[$this->staticcount]=$attrstr; $this->staticcount=$this->staticcount+1; } $this->tokstr=$this->tokstr."<font>".$tagvalue."</font>"; } else { // echo "hello2"; $this->tokstr=$this->tokstr."<font>".$tagvalue."</font>"; } } elseif($tagname=='a' && $this->mLeveltrace<$leveltrace && $this->mFlag=="true") { $attrstr; if($attname!='') { $strval=array_keys($attname); for($j=0;$j<count($attname);$j++) { $rr=$attname[$strval[$j]]; $attrstr=$attrstr." ".$strval[$j]."='".$rr."'"; $this->hypatttype[$this->hypattcount]=substr($rr,0,strlen($rr)-strlen(substr(strrchr ($rr, "/"),1))); $this->hypattcount=$this->hypattcount+1; } if($this->globalid=='size'|| $this->globalid=='style' || $this->globalid=='link' || $this->globalid=='imgtxt' && $this->globalvalue!='') { $this->hyparray[$this->hypcount]=$attrstr; // echo $this->hyparray[$this->hypcount]; $this->hypcount=$this->hypcount+1; } $this->tokstr=$this->tokstr."<a>".$tagvalue."</a>"; } else { // echo "hello2"; $this->tokstr=$this->tokstr."<a>".$tagvalue."</a>"; } } elseif($tagname=='img' && $this->mLeveltrace<$leveltrace && $this->mFlag=="true") { $attrstr; if($attname!='') { $strval=array_keys($attname); for($j=0;$j<count($attname);$j++) { $rr=$attname[$strval[$j]]; $attrstr=$attrstr." ".$strval[$j]."='".$rr."'"; } if($this->globalid=='size'|| $this->globalid=='style' || $this->globalid=='link' || $this->globalid=='imgtxt' && $this->globalvalue!='') { $this->Imgarray[$this->Imgcount]=$attrstr; // echo $this->hyparray[$this->hypcount]; $this->Imgcount=$this->Imgcount+1; } $this->tokstr=$this->tokstr."<img>".$tagvalue."</img>"; } else { // echo "hello2"; $this->tokstr=$this->tokstr."<img>".$tagvalue."</img>"; } } break; case 'cdata': if($tagname=='text' && $this->mLeveltrace==$leveltrace && $this->mFlag=="true") { $this->tokstr= $this->tokstr.$tagvalue; } if($tagname=='b' || $tagname=='i' || $tagname=='u' || $tagname=='a' || $tagname=='img' || $tagname=='font' && $this->mLeveltrace<$leveltrace && $this->mFlag=="true") { $this->tokstr= $this->tokstr.$tagvalue; } break; } } function getdata() { return $this->hypatttype; } function clearatt() { return $this->hypatttype=""; } function ReplaceOneString($getregionvalue,$stylehidden) { $this->samplestr=" "; $Expstring = strtok(trim($getregionvalue)," "); $h=1; $ll=1; while($Expstring) { if($h==$this->globalvalue && $stylehidden!='') { $substt = $Expstring; if("<".trim($stylehidden).">"!=substr($substt,strpos($substt,"<".trim($stylehidden).">"),3)) { if("<font>"==substr($substt,strpos($Expstring,"<font>"),6)) { $Expstring=str_replace("</font>","</font>",str_replace("<font>","<font"." ".$this->fontarray[$ll].">",$Expstring)); $ll=$ll+1; } if("<img></img>"== substr($Expstring,strlen($Expstring)-11,strlen($Expstring))) { $Expstring=str_replace("</img>","",str_replace("<img>","",$Expstring)); $Expstring = "<".trim($stylehidden).">".$Expstring."</".trim($stylehidden).">"; $this->samplestr = $this->samplestr." ".$Expstring."<img></img>"; } elseif("<img></img>"==substr($Expstring,0,11)) { $Expstring=str_replace("</img>","",str_replace("<img>","",$Expstring)); $Expstring = "<".trim($stylehidden).">".$Expstring."</".trim($stylehidden).">"; $this->samplestr = $this->samplestr." "."<img></img>".$Expstring; } else { $this->samplestr = $this->samplestr." "."<".trim($stylehidden).">".$Expstring."</".trim($stylehidden).">"; } } else { $this->samplestr = $this->samplestr." ".$Expstring; } } elseif("<font>"==substr($Expstring,strpos($Expstring,"<font>"),6)) { $this->samplestr = $this->samplestr." ".str_replace("</font>","</font>",str_replace("<font>","<font"." ".$this->fontarray[$ll].">",$Expstring)); $ll=$ll+1; } else { $this->samplestr = $this->samplestr." ".$Expstring; } $Expstring =strtok(" "); $h=$h+1; } //echo $this->samplestr."<br/>"; $this->fontarray=""; $final=$this->HypAddone(trim($this->samplestr),''); $finalstring=$this->ImgAddone(trim($final),''); return trim($finalstring); } function ReplaceRangeString($getregionvalue,$stylehidden,$pcount,$count) { $this->samplestr=" "; $h=1; $ll=1; $hl=1; $Expstring = strtok(trim($getregionvalue)," "); while($Expstring) { if($h>=trim($pcount) && $h<=trim($count) && $stylehidden!='') { $substt = $Expstring; if("<".trim($stylehidden).">"!=substr($substt,strpos($substt,"<".trim($stylehidden).">"),3)) { if("<font>"==substr($substt,strpos($Expstring,"<font>"),6)) { $Expstring=str_replace("</font>","</font>",str_replace("<font>","<font"." ".$this->fontarray[$ll].">",$Expstring)); $ll=$ll+1; } if("<img></img>"== substr($Expstring,strlen($Expstring)-11,strlen($Expstring))) { $Expstring=str_replace("</img>","",str_replace("<img>","",$Expstring)); $Expstring = "<".trim($stylehidden).">".$Expstring."</".trim($stylehidden).">"; $this->samplestr = $this->samplestr." ".$Expstring."<img></img>"; } elseif("<img></img>"==substr($Expstring,0,11)) { $Expstring=str_replace("</img>","",str_replace("<img>","",$Expstring)); $Expstring = "<".trim($stylehidden).">".$Expstring."</".trim($stylehidden).">"; $this->samplestr = $this->samplestr." "."<img></img>".$Expstring; } else { $this->samplestr = $this->samplestr." "."<".trim($stylehidden).">".$Expstring."</".trim($stylehidden).">"; } } else { $this->samplestr = $this->samplestr." ".$Expstring; } } elseif("<font>"==substr($Expstring,strpos($Expstring,"<font>"),6)) { //echo $Expstring.$this->fontarray[$ll]; $this->samplestr = $this->samplestr." ".str_replace("</font>","</font>",str_replace("<font>","<font"." ".$this->fontarray[$ll].">",$Expstring)); $ll=$ll+1; } else { $this->samplestr = $this->samplestr." ".$Expstring; } $Expstring =strtok(" "); $h=$h+1; } $this->fontarray=""; $final=$this->HypAddone(trim($this->samplestr),''); $finalstring=$this->ImgAddone(trim($final),''); return trim($finalstring); } function Delete($getregionvalue,$stylehidden) { $this->samplestr=" "; $Expstring = strtok(trim($getregionvalue)," "); $h=1; $ll=1; while($Expstring) { $substt = $Expstring; if($h==$this->globalvalue) { if(substr($substt,strpos($substt,"<".$stylehidden.">"),3)=="<".$stylehidden.">" ) { if("<font>"==substr($substt,strpos($Expstring,"<font>"),6)) { $Expstring=str_replace("</font>","</font>",str_replace("<font>","<font"." ".$this->fontarray[$ll].">",$Expstring)); $ll=$ll+1; } $this->samplestr=$this->samplestr." ".str_replace("</".$stylehidden.">","",str_replace("<".$stylehidden.">","",$Expstring)); } else { $this->samplestr = $this->samplestr." ".$Expstring; } } elseif("<font>"==substr($Expstring,strpos($Expstring,"<font>"),6)) { $this->samplestr = $this->samplestr." ".str_replace("</font>","</font>",str_replace("<font>","<font"." ".$this->fontarray[$ll].">",$Expstring)); $ll=$ll+1; } else { $this->samplestr = $this->samplestr." ".$Expstring; } $Expstring=strtok(" "); $h=$h+1; } $this->fontarray=""; $final=$this->HypAddone(trim($this->samplestr),''); $finalstring=$this->ImgAddone(trim($final),''); return trim($finalstring); } function FontFaceAddone($getregionvalue,$stylehidden) { $this->samplestr=" "; $h=1; $ll=1; $Expstring = strtok(trim($getregionvalue)," "); while($Expstring) { if($h==$this->globalvalue && $stylehidden!='') { $substt = $Expstring; if("<".$stylehidden!=substr($substt,strpos($substt,"<".$stylehidden),5)) { if(trim($GLOBALS[cmbFontClr])!='Empty') { $this->samplestr = $this->samplestr." "."<".$stylehidden." face='$GLOBALS[cmbFontface]' size='$GLOBALS[cmbFontsize]' color='$GLOBALS[cmbFontClr]'>".$Expstring."</font>"; } else { $this->samplestr = $this->samplestr." "."<".$stylehidden." face='$GLOBALS[cmbFontface]' size='$GLOBALS[cmbFontsize]' >".$Expstring."</font>"; } } else { if($GLOBALS['Modify']!='') { $this->samplestr = $this->samplestr." ".str_replace("</font>","</font>",str_replace("<font>","<".$stylehidden." face='$GLOBALS[cmbFontface]' size='$GLOBALS[cmbFontsize]' color='$GLOBALS[cmbFontClr]'>",$Expstring)); $ll=$ll+1; } else { $this->samplestr = $this->samplestr." ".str_replace("</font>","</font>",str_replace("<font>","<font"." ".$this->fontarray[$ll].">",$Expstring)); $ll=$ll+1; } } } elseif("<font>"==substr($Expstring,strpos($Expstring,"<font>"),6)) { $this->samplestr = $this->samplestr." ".str_replace("</font>","</font>",str_replace("<font>","<font"." ".$this->fontarray[$ll].">",$Expstring)); //echo $Expstring.$ll."3<br>"; $ll=$ll+1; } else { $this->samplestr = $this->samplestr." ".$Expstring; } $Expstring =strtok(" "); $h=$h+1; } $this->fontarray=" "; $final=$this->HypAddone(trim($this->samplestr),''); $finalstring=$this->ImgAddone(trim($final),''); return trim($finalstring); } function FontFaceAddRange($getregionvalue,$stylehidden,$pcount,$count) { $this->samplestr=" "; $h=1; $ll=1; $Expstring = strtok(trim($getregionvalue)," "); while($Expstring) { if($h>=trim($pcount) && $h<=trim($count) && $stylehidden!='') { $substt = $Expstring; if("<".$stylehidden!=substr($substt,strpos($substt,"<".$stylehidden),5)) { if(trim($GLOBALS[cmbFontClr])!='Empty') { $this->samplestr = $this->samplestr." "."<".$stylehidden." face='$GLOBALS[cmbFontface]' size='$GLOBALS[cmbFontsize]' color='$GLOBALS[cmbFontClr]'>".$Expstring."</font>"; } else { $this->samplestr = $this->samplestr." "."<".$stylehidden." face='$GLOBALS[cmbFontface]' size='$GLOBALS[cmbFontsize]'>".$Expstring."</font>"; } } else { $this->samplestr = $this->samplestr." ".str_replace("</font>","</font>",str_replace("<font>","<font"." ".$this->fontarray[$ll].">",$Expstring)); $ll=$ll+1; } } elseif("<font>"==substr($Expstring,strpos($Expstring,"<font>"),6)) { //echo "start".$Expstring.$this->fontarray[$ll]."End"; $this->samplestr = $this->samplestr." ".str_replace("</font>","</font>",str_replace("<font>","<font"." ".$this->fontarray[$ll].">",$Expstring)); //echo $Expstring.$ll."3<br>"; $ll=$ll+1; } else { $this->samplestr = $this->samplestr." ".$Expstring; } $Expstring =strtok(" "); $h=$h+1; } $this->fontarray=" "; $final=$this->HypAddone(trim($this->samplestr),''); $finalstring=$this->ImgAddone(trim($final),''); return trim($finalstring); } function DeleteFace($getregionvalue,$stylehidden) { $this->samplestr=" "; $Expstring = strtok(trim($getregionvalue)," "); $h=1; $ll=1; while($Expstring) { $substt = $Expstring; if($h==$this->globalvalue) { if(substr($substt,strpos($substt,"<".$stylehidden.">"),6)=="<".$stylehidden.">" ) { $this->samplestr=$this->samplestr." ".str_replace("</".$stylehidden.">","",str_replace("<".$stylehidden.">","",$Expstring)); $ll=$ll+1; } else { $this->samplestr = $this->samplestr." ".$Expstring; } } elseif("<font>"==substr($Expstring,strpos($Expstring,"<font>"),6)) { $this->samplestr = $this->samplestr." ".str_replace("</font>","</font>",str_replace("<font>","<font"." ".$this->fontarray[$ll].">",$Expstring)); $ll=$ll+1; } else { $this->samplestr = $this->samplestr." ".$Expstring; } $Expstring=strtok(" "); $h=$h+1; } $this->fontarray=""; $final=$this->HypAddone(trim($this->samplestr),''); $finalstring=$this->ImgAddone(trim($final),''); return trim($finalstring); } function HypAddone($getregionvalue,$stylehidden) { $regiovaluearray =array(); $this->samplestr=""; $regionvaluearray=explode(" ",$getregionvalue); $hl=1; for($i=0;$i<=count($regionvaluearray);$i++) { if("<a>"==substr($regionvaluearray[$i],strpos($regionvaluearray[$i],"<a>"),3)) { $this->samplestr = $this->samplestr." ".str_replace("</a>","</a>",str_replace("<a>","<a"." ".$this->hyparray[$hl].">",$regionvaluearray[$i])); //echo $this->hyparray[$hl].$regionvaluearray[$i]; $hl=$hl+1; } else { $this->samplestr = $this->samplestr." ".$regionvaluearray[$i]; } } $this->hyparray=''; return trim($this->samplestr); } function ImgAddone($getregionvalue,$stylehidden) { $regiovaluearray =array(); $this->samplestr=""; $regionvaluearray=explode(" ",$getregionvalue); $hl=1; for($i=0;$i<=count($regionvaluearray);$i++) { if("<img>"==substr($regionvaluearray[$i],strpos($regionvaluearray[$i],"<img>"),5)) { $this->samplestr = $this->samplestr." ".str_replace("</img>","</img>",str_replace("<img>","<img"." ".$this->Imgarray[$hl].">",$regionvaluearray[$i])); // echo $this->Imgarray[$hl].$regionvaluearray[$i]; $hl=$hl+1; } else { $this->samplestr = $this->samplestr." ".$regionvaluearray[$i]; } } $this->Imgarray=''; return trim($this->samplestr); } function FontAddone($getregionvalue,$stylehidden) { $regiovaluearray =array(); $this->samplestr=""; $regionvaluearray=explode(" ",$getregionvalue); $ll=1; for($i=0;$i<=count($regionvaluearray);$i++) { if("<font>"==substr($regionvaluearray[$i],strpos($regionvaluearray[$i],"<font>"),6)) { //echo $regionvaluearray[$i]."<br>".$this->fontarray[$ll]; $this->samplestr = $this->samplestr." ".str_replace("</font>","</font>",str_replace("<font>","<font"." ".$this->fontarray[$ll].">",$regionvaluearray[$i])); $ll=$ll+1; } else { $this->samplestr = $this->samplestr." ".$regionvaluearray[$i]; } } $this->fontarray=''; return trim($this->samplestr); } function HypLinksAddone($getregionvalue,$stylehidden) { $this->samplestr=" "; $h=1; $hl=1; $Expstring = strtok(trim($getregionvalue)," "); while($Expstring) { if($h==$this->globalvalue && $stylehidden!='') { $substt = $Expstring; if("<".$stylehidden.">"!=substr($substt,strpos($substt,"<".$stylehidden),3)) { if($GLOBALS['filename']!="Empty") { $this->samplestr = $this->samplestr." "."<".$stylehidden." href='".$GLOBALS[txtweblinks].$GLOBALS['filename']."'>".$Expstring."</a>"; } else { $this->samplestr = $this->samplestr." "."<".$stylehidden." href='$GLOBALS[txtweblinks]'>".$Expstring."</a>"; } } else { if($GLOBALS['Modify']!='') { if($GLOBALS['filename']!="Empty") { $this->samplestr = $this->samplestr." ".str_replace("</a>","</a>",str_replace("<a>","<".$stylehidden." href='".$GLOBALS[txtweblinks].$GLOBALS['filename']."'>",$Expstring)); $hl=$hl+1; } else { $this->samplestr = $this->samplestr." ".str_replace("</a>","</a>",str_replace("<a>","<".$stylehidden." href='$GLOBALS[txtweblinks]'>",$Expstring)); $hl=$hl+1; } } else { $this->samplestr = $this->samplestr." ".str_replace("</a>","</a>",str_replace("<a>","<a"." ".$this->hyparray[$hl].">",$Expstring)); $hl=$hl+1; } } } elseif("<a>"==substr($Expstring,strpos($Expstring,"<a>"),3)) { $this->samplestr = $this->samplestr." ".str_replace("</a>","</a>",str_replace("<a>","<a"." ".$this->hyparray[$hl].">",$Expstring)); $hl=$hl+1; } else { $this->samplestr = $this->samplestr." ".$Expstring; } $Expstring =strtok(" "); $h=$h+1; } $this->hyparray=" "; $final=$this->FontAddone(trim($this->samplestr),''); $finalstring=$this->ImgAddone(trim($final),''); return trim($finalstring); } function HypLinksAddRange($getregionvalue,$stylehidden,$pcount,$count) { $this->samplestr=" "; $h=1; $ll=1; $Expstring = strtok(trim($getregionvalue)," "); while($Expstring) { if($h>=trim($pcount) && $h<=trim($count) && $stylehidden!='') { $substt = $Expstring; if("<".$stylehidden.">"!=substr($substt,strpos($substt,"<".$stylehidden.">"),3)) { if($GLOBALS['filename']!="Empty") { $this->samplestr = $this->samplestr." "."<".$stylehidden." href='".$GLOBALS[txtweblinks].$GLOBALS['filename']."'>".$Expstring."</a>"; } else { $this->samplestr = $this->samplestr." "."<".$stylehidden." href='$GLOBALS[txtweblinks]'>".$Expstring."</a>"; } } else { $this->samplestr = $this->samplestr." ".str_replace("</a>","</a>",str_replace("<a>","<a"." ".$this->hyparray[$ll].">",$Expstring)); $ll=$ll+1; } } elseif("<a>"==substr($Expstring,strpos($Expstring,"<a>"),3)) { //echo "start".$Expstring.$this->fontarray[$ll]."End"; $this->samplestr = $this->samplestr." ".str_replace("</a>","</a>",str_replace("<a>","<a"." ".$this->hyparray[$ll].">",$Expstring)); //echo $Expstring.$ll."3<br>"; $ll=$ll+1; } else { $this->samplestr = $this->samplestr." ".$Expstring; } $Expstring =strtok(" "); $h=$h+1; } $this->hyparray=" "; $final=$this->FontAddone(trim($this->samplestr),''); $finalstring=$this->ImgAddone(trim($final),''); return trim($finalstring); } function DeleteHyp($getregionvalue,$stylehidden) { $this->samplestr=" "; $Expstring = strtok(trim($getregionvalue)," "); $h=1; $ll=1; while($Expstring) { $substt = $Expstring; if($h==$this->globalvalue && $stylehidden!='') { if(substr($substt,strpos($substt,"<".$stylehidden.">"),3)=="<".$stylehidden.">" ) { $this->samplestr=$this->samplestr." ".str_replace("</".$stylehidden.">","",str_replace("<".$stylehidden.">","",$Expstring)); $ll=$ll+1; } else { $this->samplestr = $this->samplestr." ".$Expstring; } } elseif("<a>"==substr($Expstring,strpos($Expstring,"<a>"),3)) { $this->samplestr = $this->samplestr." ".str_replace("</a>","</a>",str_replace("<a>","<a"." ".$this->hyparray[$ll].">",$Expstring)); $ll=$ll+1; } else { $this->samplestr = $this->samplestr." ".$Expstring; } $Expstring=strtok(" "); $h=$h+1; } $this->hyparray=" "; $final=$this->FontAddone(trim($this->samplestr),''); $finalstring=$this->ImgAddone(trim($final),''); return trim($finalstring); } function ImageInsert($getregionvalue,$stylehidden) { $this->samplestr=" "; $h=1; $hl=1; $Expstring = strtok(trim($getregionvalue)," "); while($Expstring) { if($h==$this->globalvalue && $stylehidden!='') { $substt = $Expstring; if("<".$stylehidden.">"!=substr($substt,strpos($substt,"<".$stylehidden.">"),5)) { $this->samplestr = $this->samplestr." "."<".$stylehidden." src='".adodb_sess_read('s_SelectedImage')."' width='20' height='20' border='0'></img>".$Expstring; } else { if($GLOBALS['Modify']!='') { $this->samplestr = $this->samplestr." ".str_replace("</img>","</img>",str_replace("<img>","<".$stylehidden." src='".adodb_sess_read('s_SelectedImage')."' width='20' height='20' border='0'>",$Expstring)); $hl=$hl+1; } else { $this->samplestr = $this->samplestr." ".str_replace("</img>","</img>",str_replace("<img>","<img"." ".$this->Imgarray[$hl].">",$Expstring)); $hl=$hl+1; } } } elseif("<img>"==substr($Expstring,strpos($Expstring,"<img>"),5)) { $this->samplestr = $this->samplestr." ".str_replace("</img>","</img>",str_replace("<img>","<img"." ".$this->Imgarray[$hl].">",$Expstring)); $hl=$hl+1; } else { $this->samplestr = $this->samplestr." ".$Expstring; } $Expstring =strtok(" "); $h=$h+1; } $this->Imgarray=" "; $final=$this->FontAddone(trim($this->samplestr),''); $finalstring=$this->HypAddone(trim($final),''); return trim($finalstring); } function ImageInsertNext($getregionvalue,$stylehidden) { $this->samplestr=" "; $h=1; $hl=1; $Expstring = strtok(trim($getregionvalue)," "); while($Expstring) { if($h==$this->globalvalue && $stylehidden!='') { $substt = $Expstring; if("<".$stylehidden.">"!=substr($substt,strpos($substt,"<".$stylehidden.">"),5)) { $this->samplestr = $this->samplestr." ".$Expstring."<".$stylehidden." src='".adodb_sess_read('s_SelectedImage')."' width='20' height='20' border='0'></img>"; } else { if($GLOBALS['Modify']!='') { $this->samplestr = $this->samplestr." ".str_replace("</img>","</img>",str_replace("<img>","<".$stylehidden." src='".adodb_sess_read('s_SelectedImage')."' width='20' height='20'>",$Expstring)); $hl=$hl+1; } else { $this->samplestr = $this->samplestr." ".str_replace("</img>","</img>",str_replace("<img>","<img"." ".$this->Imgarray[$hl].">",$Expstring)); $hl=$hl+1; } } } elseif("<img>"==substr($Expstring,strpos($Expstring,"<img>"),5)) { $this->samplestr = $this->samplestr." ".str_replace("</img>","</img>",str_replace("<img>","<img"." ".$this->Imgarray[$hl].">",$Expstring)); $hl=$hl+1; } else { $this->samplestr = $this->samplestr." ".$Expstring; } $Expstring =strtok(" "); $h=$h+1; } $this->Imgarray=" "; $final=$this->FontAddone(trim($this->samplestr),''); $finalstring=$this->HypAddone(trim($final),''); return trim($finalstring); } function RemoveImg($getregionvalue,$stylehidden) { $this->samplestr=" "; $Expstring = strtok(trim($getregionvalue)," "); $h=1; $ll=1; while($Expstring) { $substt = $Expstring; if($h==$this->globalvalue && $stylehidden!='') { if(substr($substt,strpos($substt,"<".$stylehidden.">"),5)=="<".$stylehidden.">" ) { $this->samplestr=$this->samplestr." ".str_replace("</".$stylehidden.">","",str_replace("<".$stylehidden.">","",$Expstring)); $ll=$ll+1; } else { $this->samplestr = $this->samplestr." ".$Expstring; } } elseif("<img>"==substr($Expstring,strpos($Expstring,"<img>"),5)) { $this->samplestr = $this->samplestr." ".str_replace("</img>","</img>",str_replace("<img>","<img"." ".$this->Imgarray[$ll].">",$Expstring)); $ll=$ll+1; } else { $this->samplestr = $this->samplestr." ".$Expstring; } $Expstring=strtok(" "); $h=$h+1; } $this->Imgarray=" "; $final=$this->FontAddone(trim($this->samplestr),''); $finalstring=$this->HypAddone(trim($final),''); return trim($finalstring); } var $stringval; var $counthypaa; function ImageHypInsert($getregionvalue,$stylehidden) { $this->samplestr=" "; $Expstring = strtok(trim($getregionvalue)," "); $h=1; $ll=1; $hl=1; while($Expstring) { $substt = $Expstring; if($h==$this->globalvalue && $stylehidden!='') { if(substr($Expstring,strpos($Expstring,"<a><img></img></a>"),18)!="<a><img></img></a>") { if(substr($Expstring,strpos($Expstring,"<img></img>"),11)=="<img></img>") { if($GLOBALS['filename']!="Empty") { $Expstring=str_replace("</img>","</img></a>",str_replace("<img>","<a href='".$GLOBALS[txtweblinks].$GLOBALS['filename']."'><img"." ".$this->Imgarray[$ll].">",$Expstring)); // echo $Expstring.$ll; $ll=$ll+1; if(substr($Expstring,strpos($Expstring,"<a>"),3)=="<a>") { $this->samplestr=$this->samplestr." ".str_replace("</a>","</a>",str_replace("<a>","<a"." ".$this->hyparray[$hl].">",$Expstring)); $hl=$hl+1; } else { $this->samplestr=$this->samplestr." ".$Expstring; } } else { $Expstring=str_replace("</img>","</img></a>",str_replace("<img>","<a href='".$GLOBALS[txtweblinks]."'><img"." ".$this->Imgarray[$ll].">",$Expstring)); // echo $Expstring.$ll; $ll=$ll+1; if(substr($Expstring,strpos($Expstring,"<a>"),3)=="<a>") { $this->samplestr=$this->samplestr." ".str_replace("</a>","</a>",str_replace("<a>","<a"." ".$this->hyparray[$hl].">",$Expstring)); $hl=$hl+1; } else { $this->samplestr=$this->samplestr." ".$Expstring; } } } } else { if(substr($Expstring,strpos($Expstring,"<img></img>"),11)=="<img></img>") { //echo $Expstring."<br>"; $Expstring=str_replace("<a></img>","</img></a>",str_replace("<a><img>","<a ".$this->hyparray[$hl]."><img"." ".$this->Imgarray[$ll].">",$Expstring)); // echo $Expstring.$ll; $ll=$ll+1; $hl=$hl+1; if(substr($Expstring,strpos($Expstring,"<a>"),3)=="<a>") { $this->samplestr=$this->samplestr." ".str_replace("</a>","</a>",str_replace("<a>","<a"." ".$this->hyparray[$hl].">",$Expstring)); $hl=$hl+1; } else { $this->samplestr=$this->samplestr." ".$Expstring; } } } } elseif(substr($Expstring,strpos($Expstring,"<a>"),3)=="<a>") { if(substr($Expstring,strpos($Expstring,"<a><img></img></a>"),18)=="<a><img></img></a>") { //echo $this->hyparray[$hl]; $Expstring=str_replace("<a></img>","</img></a>",str_replace("<a><img>","<a ".$this->hyparray[$hl]."><img"." ".$this->Imgarray[$ll].">",$Expstring)); // echo "<b>".$Expstring."one".$ll."</b>"; $ll=$ll+1; $hl=$hl+1; if(substr($Expstring,strpos($Expstring,"<a>"),3)=="<a>") { // echo "<b>".$Expstring."two".$ll."</b>"; $this->samplestr=$this->samplestr." ".str_replace("</a>","</a>",str_replace("<a>","<a"." ".$this->hyparray[$hl].">",$Expstring)); $hl=$hl+1; } else { $this->samplestr=$this->samplestr." ".$Expstring; } } elseif(substr($Expstring,strpos($Expstring,"<img></img>"),11)=="<img></img>") { $Expstring=str_replace("</img>","</img>",str_replace("<img>","<img"." ".$this->Imgarray[$ll].">",$Expstring)); $ll=$ll+1; if(substr($Expstring,strpos($Expstring,"<a>"),3)=="<a>") { $this->samplestr=$this->samplestr." ".str_replace("</a>","</a>",str_replace("<a>","<a"." ".$this->hyparray[$hl].">",$Expstring)); $hl=$hl+1; } else { $this->samplestr=$this->samplestr." ".$Expstring; } } else { $this->samplestr=$this->samplestr." ".str_replace("</a>","</a>",str_replace("<a>","<a"." ".$this->hyparray[$hl].">",$Expstring)); $hl=$hl+1; } } elseif(substr($Expstring,strpos($Expstring,"<img></img>"),11)=="<img></img>") { $this->samplestr=$this->samplestr." ".str_replace("</img>","</img>",str_replace("<img>","<img"." ".$this->Imgarray[$ll].">",$Expstring)); $ll=$ll+1; // $this->samplestr=$this->samplestr." ".$Expstring; } else { // echo $Expstring.$ll; $this->samplestr = $this->samplestr." ".$Expstring; } $Expstring=strtok(" "); $h=$h+1; } $this->Imgarray=""; $this->hyparray=""; $final=$this->FontAddone(trim($this->samplestr),''); return trim($final); } function Putvalue($regionverify,$getfinalvalue,$getftrregionvalue) { $fd = fopen($this->mMainfilename, "r+"); $contents = fread($fd,filesize($this->mMainfilename)); fclose($fd); // $this->fpp =fopen("xml/sample.xml","w+"); $parser = xml_parser_create(); xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0); xml_parse_into_struct($parser,$contents,&$vals,&$index); xml_parser_free($parser); $this->fpp1=fopen(adodb_sess_read('s_listservices_homedir')."sample1.xml","w+"); $this->mhdrvalue=$getfinalvalue; $this->mftrvalue=$getftrregionvalue; for ($i=0;$i<count($vals);$i++) { $this->WriteTag(strtolower($vals[$i][tag]),$vals[$i][type],$vals[$i][value],$vals[$i]["attributes"],trim($regionverify),$vals[$i][level]); } fclose($this->fpp1); } function WriteTag($tagname,$tagtype,$tagvalue,$attname,$regionname,$leveltrace) { switch ($tagtype) { case "open": if($tagname=='text' && $attname["name"]!=$regionname ) { $this->mLeveltrace=$leveltrace; $this->mFlag="true"; fwrite($this->fpp1,"<".$tagname); if($attname!='') { $strval=array_keys($attname); for($j=0;$j<count($attname);$j++) { $rr=$attname[$strval[$j]]; fwrite($this->fpp1," ".$strval[$j]."='".$rr."'"); } } fwrite($this->fpp1,">$this->mftrvalue"); } elseif($tagname=='text' && $attname["name"]==$regionname) { $this->tagset="true"; fwrite($this->fpp1,"<".$tagname); if($attname!='') { $strval=array_keys($attname); for($j=0;$j<count($attname);$j++) { $rr=$attname[$strval[$j]]; fwrite($this->fpp1," ".$strval[$j]."='".$rr."'"); } } fwrite($this->fpp1,">$this->mhdrvalue"); // echo "<br/><b>".$this->samplestr."</b>"; } else { if($tagname=='b' || $tagname=='i' || $tagname=='u' || $tagname=='font' || $tagname=='a' || $tagname=='img') { } else { fwrite($this->fpp1,"<".$tagname); if($attname!='') { $strval=array_keys($attname); for($j=0;$j<count($attname);$j++) { $rr=$attname[$strval[$j]]; fwrite($this->fpp1," ".$strval[$j]."='".$rr."'"); } } fwrite($this->fpp1,">$tagvalue"); } } break; case "close": if($tagname=='text' ) { fwrite($this->fpp1,"</".$tagname.">n"); $this->mFlag="false"; } else { if($tagname=='b' || $tagname=='i' || $tagname=='u' || $tagname=='font' || $tagname=='a' || $tagname=='img') { } else { fwrite($this->fpp1,"</".$tagname.">"); } } break; case "complete": if($tagname=='text' && $attname["name"]!=$regionname ) { $this->mLeveltrace=$leveltrace; // $this->mFlag="true"; fwrite($this->fpp1,"<".$tagname); if($attname!='') { $strval=array_keys($attname); for($j=0;$j<count($attname);$j++) { $rr=$attname[$strval[$j]]; fwrite($this->fpp1," ".$strval[$j]."='".$rr."'"); } } fwrite($this->fpp1,">$this->mftrvalue</$tagname>"); } elseif($tagname=='text' && $attname["name"]==$regionname) { $this->tagset="true"; fwrite($this->fpp1,"<".$tagname); if($attname!='') { $strval=array_keys($attname); for($j=0;$j<count($attname);$j++) { $rr=$attname[$strval[$j]]; fwrite($this->fpp1," ".$strval[$j]."='".$rr."'"); } } fwrite($this->fpp1,">$this->mhdrvalue</$tagname>n"); } else { if($tagname=='b' || $tagname=='i' || $tagname=='u' || $tagname=='font' || $tagname=='a' || $tagname=='img') { } else { fwrite($this->fpp1,"<".$tagname); if($attname!='') { $strval=array_keys($attname); for($j=0;$j<count($attname);$j++) { $rr=$attname[$strval[$j]]; fwrite($this->fpp1," ".$strval[$j]."='".$rr."'"); } } fwrite($this->fpp1,">$tagvalue</$tagname>"); } } break; } } function Finaltransfer() { $fpp3 =fopen(adodb_sess_read('s_listservices_homedir')."sample1.xml","r+"); $content = fread($fpp3,filesize(adodb_sess_read('s_listservices_homedir')."sample1.xml")); fclose($fpp3); if($content!='') { $fpp3 = fopen($this->mMainfilename,"w+"); fwrite($fpp3,$content); fclose($fpp3); } } } ?>