CodeIgniter Forums
CI2 make robots.txt file problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: CI2 make robots.txt file problem (/showthread.php?tid=39951)



CI2 make robots.txt file problem - El Forum - 03-25-2011

[eluser]smartweb[/eluser]
Codeigniter version:2.0
Function: Make robots.txt
Problem: use notpad to view the robts.txt is not well, too many space.
++++++++++++++++++++++++++++
View:
<textarea id="readtxt" name="readtxt" style="width:100%;height:300px;" ><?php echo set_value('readtxt',$readtxt); ?></textarea>
+++++++++++++++++++++++++++++
Control:
$txt="robots.txt";
if(read_file($txt)Wink
{$output=read_file($txt);}
else
{
$output="User-agent: *
Allow: /
Sitemap: http://".$_SERVER['SERVER_NAME']."/sitemap.xml";
write_file($txt, $output,'a+');
}
$output=str_replace("\n","",$output);
$data['readtxt']=$output;

$output=$this->input->post('readtxt');
$output=(str_replace("","\n",$output));
write_file($txt, $output,'r+');
$data['success'] = '<div class="suc">Finish!</div>';
$output=read_file($txt);
$output=str_replace("\n","",$output);
$data['readtxt']=$output;
$this->load->view('edit_robots_txt',$data);