"; } //open the file $fp = fopen($filename,"w"); //save the file fputs($fp,$content); //close the file fclose($fp); } } /**************************************************** This method make a file *****************************************************/ function MakeFile($filename, $content) { //checks if the file exists if (!file_exists($filename)) { echo "Couldn't find datafile, please contact administrator!"; } else { $fp = fopen($filename,"w"); fputs($fp,$content); fclose($fp); } } /**************************************************** This method replaces words in the file *****************************************************/ function ReplaceWords($filename, $newword, $oldword) { //checks if the file exists if (!file_exists($filename)) { echo "Couldn't find datafile, please contact administrator!"; } else { $newfile = fopen($filename,"r"); $content = fread($newfile, filesize($filename)); fclose($newfile); //replace the word $content = str_replace($oldword, $newword, $content); //open the file $fp = fopen($filename,"w"); //save the file fputs($fp,$content); //close the file fclose($fp); } } /**************************************************** This method replaces a line in a file *****************************************************/ function ReplaceLine($filename, $linenr, $addcontent) { //checks if the file exists if (!file_exists($filename)) { echo "Couldn't find datafile, please contact administrator!"; } else { $newfile = file($filename); $content; for ($i=0;$i"; else $content .= $newfile[$i]."
"; } //open the file $fp = fopen($filename,"w"); //save the file fputs($fp,$content); //close the file fclose($fp); } } /**************************************************** This method replaces a line in a file before a given one *****************************************************/ function InsertLineBefore($filename, $linenr, $addcontent) { //checks if the file exists if (!file_exists($filename)) { echo "Couldn't find datafile, please contact administrator!"; } else { $newfile = file($filename); $content; for ($i=0;$i"; $content .= $newfile[$i]."
"; } //open the file $fp = fopen($filename,"w"); //save the file fputs($fp,$content); //close the file fclose($fp); } } /**************************************************** This method replaces a line in a file after a given one *****************************************************/ function InsertLineAfter($filename, $linenr, $addcontent) { //checks if the file exists if (!file_exists($filename)) { echo "Couldn't find datafile, please contact administrator!"; } else { $newfile = file($filename); $content; for ($i=0;$i"; if(($i+1) == $linenr) $content .= $addcontent."
"; } //open the file $fp = fopen($filename,"w"); //save the file fputs($fp,$content); //close the file fclose($fp); } } } ?>