#!/usr/bin/php -Cq Error:
"; die ("Can't connect to the db"); } $query="select * from proxy order by pname desc"; $result = mysql_db_query("irm",$query); while ($r = mysql_fetch_array($result)) { $myentry =""; $proxy_on = $r["proxy_on"]; $indexpage = $r["indexpage"]; $name = $r["pname"]; $alias = $r["alias"]; $relative = $r["relative"]; $indexurl=explode("/", $indexpage); $indexuri=$indexurl[2]; $indexlink=str_replace("http://$indexuri", "", "$indexpage"); $aliases=explode(",", $alias); $myaliases=count($aliases); $entry=" DocumentRoot /var/www/localhost/htdocs/proxy ServerName $name "; if("$alias"!="") { for($y=0; $y<$myaliases; $y++) { if(isset($aliases[$y])) { $entry.=" ServerAlias $aliases[$y] "; } else { $myaliases++; } } } if("$relative"=="1") { $entry.=" ProxyPass / http://$indexuri$indexlink ProxyPassReverse / http://$indexuri$indexlink "; } else { $entry.=" RewriteEngine On RewriteRule ^/\$ $indexlink [R] RewriteRule ^/(.+)\$ http://$indexuri/\$1 [P] ProxyPassReverse / http://$indexuri/ ProxyPreserveHost On "; } $entry.="\n"; $myentry="$entry "."$myentry"; $newentry="$myentry "."$newentry"; } PRINT "$newentry"; mysql_free_result($result); exit; $file="/home/jim/etc/vhosts.conf"; $main=file_get_contents($file); $newfile="$main"."$newentry"; //PRINT "$newfile"; $tmpfname = tempnam("/tmp", "vhosts."); $fp=fopen($tmpfname, "w+"); fwrite($fp, ($newfile)); fclose ($fp); ?>