<?php
// There were errors when last run on "other half"
// because the @?@>@ line was combined with price.
// BE VERY CAREFUL in terms of testing & modifying.
// USE S-array to load up domain names/SITES (w/ prices)
$s = array();
$p = array();
$fh = fopen("atom.txt", "r");
$n = 0;
// $l = trim(fgets($fh)); ... Is there a header record or not?
while (!feof($fh)) {
$l = trim(fgets($fh));
if ( strpos( $l, "ering")> 0 ) break;
if ( substr( $l, 0,1 ) == "*" ) continue;
$l = trim(substr($l,1,99));
if ( strlen($l) < 5 ) break;
$i = strpos($l,",") ;
$s[$n] = trim (substr($l,0, $i));
$p[$n] = trim( substr($l,$i+1,99));
$n++;
}
fclose($fh);
/*
print_r ($s);
echo "<br>";
print_r ($p);
exit;
*/
// Then WE READ IN THE new master (indexx.php) file INTO A-ARRAY;
// REMEMBER, gotta do half of the names - APPLIES BELOW!!! - in the other NC "forest!!!!!!!!!!!!!!!"
$a = array();
$fh = fopen("indexx.php", "r");
$n = 1;
while (!feof($fh)) {
$l = trim(fgets($fh));
if ( strlen($l) < 2 ) continue;
$a[$n] = $l;
$n++;
if ( strpos($l, "</html") > 0 ) { $alen = $n;
break; }
}
fclose($fh) ;
$anum = array_search( "?>", $a );
if ( $anum <1 || $anum > 99) {echo "BIG SURPRISE<br>";
echo "a(2)->" . $a[2] . "<<br>";
echo "a(3)->" . $a[3] . "<<br>";
echo "a(4)->" . $a[4] . "<<br>";
echo "a(5)->" . $a[5] . "<<br>";
echo "a(6)->" . $a[6] . "<<br>";
exit; }
$c = 0; // used to COUNT # of sites we "modify"
// Filter for the ones which EXIST in this half
for ( $h=0; $h <399; $h++ ) {
$a1 = trim($s[$h]);
$pp = $p[$h];
$a1 = trim( substr($a1,0,99));
$a1 = substr($a1,0, strlen($a1)-1);
$v = strpos($a1, ".");
if ( ! ($v>3 && $v<63) )
{echo "v->" . $v ;
exit; }
// Put back 'or $c>0||1||2 etc.' if you ever need to test again! 0 gets you just 1 site processed!! (if 1 in next line -> 2 towns)
// if ( $c > 1 ) break;
$cdtarget = chr(47) . "home" . chr(47) . "upbeatmm" . chr(47) . $a1 ;
// cdtarget = /home/peteukke/sellingbriarcliffmanor.com ... holdover from earlier program. (Above guy shd be like this!
$cdt = strtolower(trim($cdtarget)."/index.php");
echo "cdt->" . $cdt . "<<br>";
copy( $cdt, "index.php");
$i = strpos( $cdt, "index");
$cdt2 = strtolower(substr( $cdt, 0, $i+5) . "x.php");
echo "cdt2->" . $cdt2 . "<<br>"; // Lets us know which SITE we're dealing with...
$fh = fopen( "index.php", "r") ;
$fo = fopen( "index_NEW.php", "w") ;
$n=0;
for ($i=0; $i <99; $i++) {
$l = trim(fgets($fh));
if ( strlen($l) < 2 ) continue;
$n++;
if ( strpos($l, "price")>1) {
$l = substr($l,0,9) . $pp .";" ;
}
if ( strpos("~~".$l, "?>") == 0) { fwrite($fo, $l."\n") ;
continue ;}
fwrite($fo, $l."\n") ;
break;
}
fclose($fh);
/*
for ($i=5; $i <199; $i++) {
$l = $a[$i];
if ( strlen($l) < 2 ) continue;
fwrite($fo, $l."\n") ;
if ( strpos($l, "</html") > 0) { echo "EUREKA" . "<br>" ;
break; }
}
*/
for ($i=$anum+1; $i <$alen; $i++) {
fwrite($fo, $a[$i]."\n");
}
fclose($fo) ;
$c++ ; // serves no purpose once testing is complete!
copy("index_NEW.php", $cdt);
/*
$v = "atom-favicon.png";
$v1 = substr($cdt2,0,strlen($cdt2)-10) . $v;
copy($v, $v1);
$v = "style3.css";
$v1 = substr($cdt2,0,strlen($cdt2)-10) . $v;
copy($v, $v1);
$v = "dollar.png";
$v1 = substr($cdt2,0,strlen($cdt2)-10) . $v;
copy($v, $v1);
*/
} // Closing the master loop covering all the sites in "this half."
?>