Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/php -q
- <?
- $dbhost="localhost";
- $dbuser="pdns_temp";
- $dbpassword="pdns123";
- $dbname="pdns_temp";
- $logfile="/var/run/dnssync/log";
- @mysql_connect($dbhost,$dbuser,$dbpassword) or print ("***Kan ej ansluta mot databas!***\n\n");
- @mysql_select_db($dbname);
- if ($handle = opendir('/var/run/dnssync/run')) {
- $files=array();
- while (false !== ($file = readdir($handle))) {
- if(preg_match('/run/i',$file)) {
- $wrk_file = $file;
- array_push($files,$wrk_file);
- }
- }
- closedir($handle);
- }
- for($x=0;$x<sizeof($files);$x++) {
- $tmp_content = file_get_contents("/var/run/dnssync/run/$files[$x]");
- $content = explode(" ",$tmp_content);
- $username = $content[0]; $domain = trim($content[1]);
- $q = mysql_query("UPDATE domains SET cust_id='$username' WHERE name='$domain'");
- $ql = "UPDATE domains SET cust_id='$username' WHERE name='$domain'";
- if (!$q) {
- $fh = fopen($logfile,a);
- $logstring = date("Y-m-d H:i").' '.mysql_error()."\n";
- fwrite($fh,$logstring);
- fclose($fh);
- die();
- }
- $fh = fopen($logfile,a);
- $logstring = date("Y-m-d H:i").' '.$ql."\n";
- fwrite($fh,$logstring);
- fclose($fh);
- $q2=mysql_query("SELECT id FROM domains WHERE name='$domain'");
- $q2l="SELECT id FROM domains WHERE name='$domain'";
- if (!$q2) {
- $fh = fopen($logfile,a);
- $logstring = date("Y-m-d H:i").' '.mysql_error()."\n";
- fwrite($fh,$logstring);
- fclose($fh);
- die();
- }
- $fh = fopen($logfile,a);
- $logstring = date("Y-m-d H:i").' '.$q2l."\n";
- fwrite($fh,$logstring);
- fclose($fh);
- $id_tmp = mysql_fetch_row($q2); $domain_id = $id_tmp[0];
- $q3=mysql_query("INSERT INTO domain_owners (domain_id,user_id) VALUES ('$domain_id','103')");
- $q3l="INSERT INTO domain_owners (domain_id,user_id) VALUES ('$domain_id','103')";
- if (!$q3) {
- $fh = fopen($logfile,a);
- $logstring = date("Y-m-d H:i").' '.mysql_error()."\n";
- fwrite($fh,$logstring);
- fclose($fh);
- die();
- }
- $fh = fopen($logfile,a);
- $logstring = date("Y-m-d H:i").' '.$q3l."\n";
- fwrite($fh,$logstring);
- fwrite($fh,date("Y-m-d H:i")." Deleting $files[$x]\n");
- unlink("/var/run/dnssync/run/$files[$x]");
- fwrite($fh,date("Y-m-d H:i")."---MARK---\n");
- fclose($fh);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement