Maybe this will help...
<?
$input_file="java.txt"; //specify the input file
$output_dir="output/"; //specify the output directory
$lines=file($input_file); //split the file as an array with each line as a new array part
if($lines) //check to make sure that there is data
{
foreach($lines as $line) //time to cycle through each line at a time
{
$line=trim($line); //trim the empty spaces
if(!empty($line)) //make sure that the line isn't blank
{
$tmp=explode("||",$line); //split the line by the text and the filename
$java=$tmp[0]; // set the javascript to be $java
$keyword=$tmp[1]; // set the filename to be $keyword
//all this does is manipulate the javascript and get it into a format for the file write
$to_write="<script type=\"text/javascript\">document.write('";
for ($c=0; $c<strlen($java); $c++)
{
$to_write .= "\u";
$h = 4 - strlen(dechex(ord($java[$c])));
for ($p=0; $p<$h; $p++) $to_write .= "0";
$to_write .= dechex(ord($java[$c]));
}
$to_write.="')</script>";
save_file($keyword,$to_write); // now we have the filename and the format
//for the write - lets do the function call
}
}
}
//save the file function call
function save_file($name,$content)
{
global $output_dir;
//open the file for writing
$fp=fopen($output_dir.$name.".txt","w");
if($fp)
{
fputs($fp,$content); //write the data
}
@fclose($fp); //close the file stream down
}
?>
What you now have to look at, is instead of getting the javascript piece by piece, or $line by $line, split into $keyword and $java, you will have lines of only $java.
So by changing as follows :
<?
$input_file="java.txt"; //specify the input file
$output_dir="output/"; //specify the output directory
$keyword_name = "name.txt"; //specify the output file
$lines=file($input_file); //split the file as an array with each line as a new array part
$to_write="<script type=\"text/javascript\">document.write('"; //start the variable to write to the file
if($lines) //check to make sure that there is data
{
foreach($lines as $line) //time to cycle through each line at a time
{
$line=trim($line); //trim the empty spaces
if(!empty($line)) //make sure that the line isn't blank
{
//all this does is manipulate the javascript and get it into a format for the file write
for ($c=0; $c<strlen($line); $c++)
{
$to_write .= "\u";
$h = 4 - strlen(dechex(ord($line[$c])));
for ($p=0; $p<$h; $p++) $to_write .= "0";
$to_write .= dechex(ord($line[$c]));
}
}
}
}
$to_write.="')</script>"; //end the variable to write
save_file($keyword,$to_write); // now we have the filename and the format
//for the write - lets do the function call
//save the file function call
function save_file($name,$content)
{
global $output_dir;
//open the file for writing
$fp=fopen($output_dir.$name.".txt","w");
if($fp)
{
fputs($fp,$content); //write the data
}
@fclose($fp); //close the file stream down
}
?>
SHould give the full file instead of a split...