<?php
if(isset($_POST['fecha'])){$pfecha=$_POST['fecha'];}
	if(1==2)
	{
					$panio=substr($pfecha,0,4);	
					$pmes=substr($pfecha,5,2);	
					$pdia=substr($pfecha,8,2);	

					$jworg='http://wol.jw.org';
					$jworg1=$jworg.'/es/wol/dt/r4/lp-s/'.$panio.'/'.$pmes.'/'.$pdia;

					$page = file_get_contents($jworg1);
					$sec0 = strpos($page,'<h2 id="p2"');
					$sec1 = strpos($page,'id="section1"');
					$sec2 = strpos($page,'id="section2"');
					$sec3 = strpos($page,'id="section3"');
					$sec4 = strpos($page,'id="section4"');
					$sec5 = strpos($page,'<strong>Estudio bíblico de la congregación');
					$sec6 = strpos($page,'SEMANA DEL');

					$sec0 = substr($page,$sec0,$sec1-$sec0); 
					$stdb = substr($page,$sec2,$sec3-$sec2); 
					$ssmm = substr($page,$sec3,$sec4-$sec3); 
					$snvc = substr($page,$sec4,$sec5-$sec4); 
					$slib = substr($page,$sec5,$sec6-$sec5); 
					$sata = substr($page,$sec6,9999999); 

					$tdb1 = substr($stdb,strpos($stdb,'<a href='),strpos($stdb,'</a')-strpos($stdb,'<a href=')); 
					$tdb1 = str_replace('href="','target="_blank" href="'.$jworg,$tdb1);
					$tdb1 = str_replace('strong','div',$tdb1);

					$tdb2 = substr($sec0,strpos($sec0,'<a href='),strpos($sec0,'</a')-strpos($sec0,'<a href=')); 
					$tdb2 = str_replace('href="','target="_blank" href="'.$jworg,$tdb2);
					$tdb2 = str_replace('strong','div',$tdb2);
					$tdb2 = str_replace('>','> ',$tdb2);
					$tdb2 = ucwords(strtolower($tdb2));


					$smm0 = substr($stdb,strpos($stdb,'ideas de la lectura'),999999999); 
					$smm0 = substr($smm0,strpos($smm0,'<li>'),strpos($smm0,'</li>')-strpos($smm0,'<li>')); 
					$smm0 = str_replace('href="','target="_blank" href="'.$jworg,$smm0);
 					$smm0 = str_replace('):','):<br>',$smm0);


					$smm00=$ssmm;
					$smm1 = substr($smm00,strpos($smm00,'<li>'),strpos($smm00,'</li>')-strpos($smm00,'<li>')); 
					$smm1 = str_replace('href="','target="_blank" href="'.$jworg,$smm1);
 					$smm1 = str_replace('):','):<br>',$smm1);
//  					$smm1 = str_replace('. ','. <br>',$smm1);
//  					$smm1 = str_replace('. <br>o','. o',$smm1);
 					$smm1 = str_replace('</a>','</a><br>',$smm1);

					$smm00=substr($smm00,strpos($smm00,'</li>')+5,$sec4-strpos($smm00,'</li>'));
					$smm2 = substr($smm00,strpos($smm00,'<li>'),strpos($smm00,'</li>')-strpos($smm00,'<li>')); 
					$smm2 = str_replace('href="','target="_blank" href="'.$jworg,$smm2);
 					$smm2 = str_replace('):','):<br>',$smm2);
//  					$smm2 = str_replace('. ','. <br>',$smm2);
//  					$smm2 = str_replace('. <br>o','. o',$smm2);
 					$smm2 = str_replace('</a>','</a><br>',$smm2);

					$smm00=substr($smm00,strpos($smm00,'</li>')+5,$sec4-strpos($smm00,'</li>'));
					$smm3 = substr($smm00,strpos($smm00,'<li>'),strpos($smm00,'</li>')-strpos($smm00,'<li>')); 
					$smm3 = str_replace('href="','target="_blank" href="'.$jworg,$smm3);
 					$smm3 = str_replace('):','):<br>',$smm3);
//  					$smm3 = str_replace('. ','. <br>',$smm3);
//  					$smm3 = str_replace('. <br>o','. o',$smm3);
 					$smm3 = str_replace('</a>','</a><br>',$smm3);

					$nvc0=$snvc;
					$nvc0 = substr($nvc0,strpos($nvc0,'</li>')+5,999999); 
					$nvc1 = substr($nvc0,strpos($nvc0,'<a href='),strpos($nvc0,'</a')-strpos($nvc0,'<a href=')); 
					$nvc1 = str_replace('href="','target="_blank" href="'.$jworg,$nvc1);
					$nvc1 = str_replace('strong','div',$nvc1);

					$nvc0 = substr($nvc0,strpos($nvc0,'</li>')+5,999999); 
					$nvc2 = substr($nvc0,strpos($nvc0,'<a href='),strpos($nvc0,'</a')-strpos($nvc0,'<a href=')); 
					$nvc2 = str_replace('href="','target="_blank" href="'.$jworg,$nvc2);
					$nvc2 = str_replace('strong','div',$nvc2);

					$ata0 = $sata;
					$ata1 = substr($ata0,strpos($ata0,'<a'),strpos($ata0,'</a')-strpos($ata0,'<a')); 
					$ata1 = str_replace('href="','target="_blank" href="'.$jworg,$ata1);
					$ata1 = str_replace('strong','div',$ata1);

					$lib0 = $slib;
					$lib1 = substr($lib0,strpos($lib0,'<a'),strpos($lib0,'</a')-strpos($lib0,'<a')); 
					$lib1 = str_replace('href="','target="_blank" href="'.$jworg,$lib1);
					$lib1 = str_replace('strong','div',$lib1);

	}


if(isset($_POST['fecha']))
{
	echo '<resul>';
	echo '<tdb1>'.$tdb1.'</tdb1>';
	echo '<tdb2>'.$tdb2.'</tdb2>';
	echo '<smm0>'.$smm0.'</smm0>';
	echo '<smm1>'.$smm1.'</smm1>';
	echo '<smm2>'.$smm2.'</smm2>';
	echo '<smm3>'.$smm3.'</smm3>';
	echo '<nvc1>'.$nvc1.'</nvc1>';
	echo '<nvc2>'.$nvc2.'</nvc2>';
	echo '<ata1>'.$ata1.'</ata1>';
	echo '<lib1>'.$lib1.'</lib1>';
	echo '</resul>';
}
?>