cursed
09-01-2006, 01:09 AM
Whats wrong with this PHP file?
<?php $affiliate = 'somesite.com'; //Don't add anything that isn't ALWAYS in the URL
if(strpos(strtolower($_SERVER['HTTP_REFERER']),$affiliate) !== false){
//this writes to text
$filename = 'link.txt';
$somecontent = "\n Gimya.com<BR>TESTTESTTESTTEST<HR><HR> \n";
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo " somthings wrong with ($filename) ";
exit;
}
echo "SUCESS. ($somecontent) to file ($filename)";
fclose($handle);
//
}
}
else
function deleteline($del,$filename){
$file = file($filename);
ob_start();
for($i=0;$i < count($file);$i++){
if(strpos($file[$i],$del) === FALSE){
echo $file[$i];
}
}
$write = ob_get_contents();
ob_end_clean();
$handle = fopen('link.txt','w');
fwrite($handle,$write);
fclose($handle);
}
//Pass in the search term, then the filename
deleteline('google','link.txt');
?>
<?php $affiliate = 'somesite.com'; //Don't add anything that isn't ALWAYS in the URL
if(strpos(strtolower($_SERVER['HTTP_REFERER']),$affiliate) !== false){
//this writes to text
$filename = 'link.txt';
$somecontent = "\n Gimya.com<BR>TESTTESTTESTTEST<HR><HR> \n";
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo " somthings wrong with ($filename) ";
exit;
}
echo "SUCESS. ($somecontent) to file ($filename)";
fclose($handle);
//
}
}
else
function deleteline($del,$filename){
$file = file($filename);
ob_start();
for($i=0;$i < count($file);$i++){
if(strpos($file[$i],$del) === FALSE){
echo $file[$i];
}
}
$write = ob_get_contents();
ob_end_clean();
$handle = fopen('link.txt','w');
fwrite($handle,$write);
fclose($handle);
}
//Pass in the search term, then the filename
deleteline('google','link.txt');
?>