Advertisement
johnburn

[danginxvhost.php] Decoded for: [email protected]

Jul 19th, 2011
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.73 KB | None | 0 0
  1. <?php
  2. include ("lib.php");
  3. $lines = file("/etc/danginx/data.conf");
  4. foreach($lines as $key) {
  5.     $term = explode(":", trim($key));
  6.     if ($term[0] == "LICENSE") {
  7.         $key = $term[1];
  8.         break;
  9.         break;
  10.     }
  11. }
  12. $licensekey = $key;
  13. $localkey = shell_exec("/bin/cat /etc/danginx/localkey.txt");
  14. $results = check_license($licensekey, $localkey);
  15. if ($results['status'] == "Active") {
  16.     $vhostDate = "#Auto generated vhost configuration by Da Nginix. Any customization will be lost\n";
  17.     $DBINO = array();
  18.     $GLOBIP = "";
  19.     if ($handle = opendir("/usr/local/directadmin/data/users")) {
  20.         $_file_list = "";
  21.         while (false !== ($file = readdir($handle))) {
  22.             if ($file != "." && $file != "..") {
  23.                 $_file_list.= $file . ":";
  24.             }
  25.         }
  26.         closedir($handle);
  27.     }
  28.     $cPuser = explode(":", $_file_list);
  29.     sort($cPuser);
  30.     $ArrLen = count($cPuser);
  31.     $cpUsernumber = $ArrLen - 1;
  32.     $i = 1;
  33.     while ($i <= $cpUsernumber) {
  34.         $USER = $cPuser[$i];
  35.         $domain = file("/usr/local/directadmin/data/users/{$USER}/domains.list");
  36.         $dom_count = count($domain);
  37.         $j = 0;
  38.         while ($j < $dom_count) {
  39.             $DOMAIN = trim($domain[$j]);
  40.             $ux = file("/usr/local/directadmin/data/users/{$USER}/user.conf");
  41.             foreach($ux as $line_num => $line) {
  42.                 if (preg_match("/^ip=/", $line)) {
  43.                     $ipdata = explode("=", $line);
  44.                     $GLOBIP = trim($ipdata[1]);
  45.                     break;
  46.                     break;
  47.                 }
  48.             }
  49.             if (file_exists("/usr/local/directadmin/data/users/{$USER}/domains/{$DOMAIN}.conf")) {
  50.                 $uf = file("/usr/local/directadmin/data/users/{$USER}/domains/{$DOMAIN}.conf");
  51.                 foreach($uf as $line_num => $line) {
  52.                     if (preg_match("/^ip=/", $line)) {
  53.                         $ipdata = explode("=", $line);
  54.                         $DOMIP = trim($ipdata[1]);
  55.                         break;
  56.                     }
  57.                     $DOMIP = $GLOBIP;
  58.                 }
  59.                 $DOMDOCROOT = "/home/{$USER}/domains/{$DOMAIN}/public_html";
  60.                 $ACCESSLOG = "/var/log/httpd/domains/{$DOMAIN}.log";
  61.             }
  62.             if (file_exists("/etc/danginx/expires/{$DOMAIN}") && filesize("/etc/danginx/expires/{$DOMAIN}") != 0) {
  63.                 $exp_line = file("/etc/danginx/expires/{$DOMAIN}");
  64.                 $EXPIRE = trim($exp_line[0]);
  65.             } else {
  66.                 $EXPIRE = "24h";
  67.             }
  68.             if (file_exists("/etc/danginx/custom/{$DOMAIN}") && filesize("/etc/danginx/custom/{$DOMAIN}") != 0) {
  69.                 $CUSTOM = "include \"/etc/danginx/custom/" . $DOMAIN . "\"";
  70.             } else {
  71.                 $CUSTOM = "#include \"/etc/danginx/custom/" . $DOMAIN . "\"";
  72.             }
  73.             $fval = "{$DOMAIN}" . "|" . "{$DOMIP}" . "|" . "{$DOMDOCROOT}" . "|" . "{$ACCESSLOG}" . "|" . "{$EXPIRE}" . "|" . "{$CUSTOM}";
  74.             $DBINO[] = $fval;
  75.             $POINTERFILE = "/usr/local/directadmin/data/users/{$USER}/domains/{$DOMAIN}.pointers";
  76.             if (file_exists($POINTERFILE) && filesize("{$POINTERFILE}") != 0) {
  77.                 $PDOMAIN = array();
  78.                 $pfile = file($POINTERFILE);
  79.                 foreach($pfile as $line_num => $line) {
  80.                     $tmx = explode("=alias", $line);
  81.                     $PDOMAIN[$line_num] = trim($tmx[0]);
  82.                 }
  83.                 foreach($PDOMAIN as $XDOMAIN) {
  84.                     $fval = "{$XDOMAIN}" . "|" . "{$DOMIP}" . "|" . "{$DOMDOCROOT}" . "|" . "{$ACCESSLOG}" . "|" . "{$EXPIRE}" . "|" . "{$CUSTOM}";
  85.                     $DBINO[] = $fval;
  86.                 }
  87.             }
  88.             if (file_exists("/usr/local/directadmin/data/users/{$USER}/domains/{$DOMAIN}.subdomains")) {
  89.                 $subdomain = file("/usr/local/directadmin/data/users/{$USER}/domains/{$DOMAIN}.subdomains");
  90.                 $subdom_count = count($subdomain);
  91.                 if (0 < $subdom_count) {
  92.                     $k = 0;
  93.                     while ($k < $subdom_count) {
  94.                         $sub = trim($subdomain[$k]);
  95.                         $SUBDOMAIN = "{$sub}" . "." . "{$DOMAIN}";
  96.                         $SUBDOCROOT = "/home/{$USER}/domains/{$DOMAIN}/public_html/{$sub}";
  97.                         $SUBACCESSLOG = "/var/log/httpd/domains/{$DOMAIN}.{$sub}.log";
  98.                         if (file_exists("/etc/danginx/expires/{$SUBDOMAIN}") && filesize("/etc/danginx/expires/{$SUBDOMAIN}") != 0) {
  99.                             $exp_line = file("/etc/danginx/expires/{$SUBDOMAIN}");
  100.                             $EXPIRE = trim($exp_line[0]);
  101.                         } else {
  102.                             $EXPIRE = "24h";
  103.                         }
  104.                         if (file_exists("/etc/danginx/custom/{$SUBDOMAIN}") && filesize("/etc/danginx/custom/{$SUBDOMAIN}") != 0) {
  105.                             $CUSTOM = "include \"/etc/danginx/custom/" . $SUBDOMAIN . "\"";
  106.                         } else {
  107.                             $CUSTOM = "#include \"/etc/danginx/custom/" . $SUBDOMAIN . "\"";
  108.                         }
  109.                         $fval = "{$SUBDOMAIN}" . "|" . "{$DOMIP}" . "|" . "{$SUBDOCROOT}" . "|" . "{$SUBACCESSLOG}" . "|" . "{$EXPIRE}" . "|" . "{$CUSTOM}";
  110.                         $DBINO[] = $fval;
  111.                         ++$k;
  112.                     }
  113.                 }
  114.             }
  115.             ++$j;
  116.         }
  117.         ++$i;
  118.     }
  119.     $vhlines = file("/etc/danginx/vhost.conf");
  120.     $PROXYCONF = "\n";
  121.     foreach($vhlines as $key) {
  122.         $PROXYCONF.= "  " . $key;
  123.     }
  124.     $linesext = file("/etc/danginx/fileextensions.txt");
  125.     foreach($linesext as $key) {
  126.         if (preg_match("/\\|/", $key)) {
  127.             $file_est = trim($key);
  128.         }
  129.     }
  130.     foreach($DBINO as $DB) {
  131.         $tmpar = explode("|", $DB);
  132.         $DOMAIN = $tmpar[0];
  133.         $DOMIP = $tmpar[1];
  134.         $DOMDOCROOT = $tmpar[2];
  135.         $ACCESSLOG = $tmpar[3];
  136.         $EXPIRETIME = $tmpar[4];
  137.         $CUSTOMINCLUDE = $tmpar[5];
  138.         if (!file_exists("/etc/danginx/direct/{$DOMAIN}")) {
  139.             $vhostDate.= "#################################################################\n########### Vhost configuration of  {$DOMAIN}\n#################################################################\nserver {\naccess_log off;\nerror_log  logs/vhost-error_log warn;\nlisten    80;\nserver_name  {$DOMAIN} www.{$DOMAIN};\nlocation ~* ^.+.({$file_est})$ {\n        expires {$EXPIRETIME};\n        root {$DOMDOCROOT};\n        error_page  404 = @apache;\n        access_log  {$ACCESSLOG};\n        log_not_found  off;\n        }\nlocation ~ /\\.ht {\n          deny all;\n        }\n\nlocation / {\n        log_not_found  off;\n{$PROXYCONF}\n        proxy_redirect  http://www.{$DOMAIN}:8888   http://www.{$DOMAIN};\n        proxy_redirect  http://{$DOMAIN}:8888   http://{$DOMAIN};\n        proxy_pass   http://{$DOMIP}:8888/;\n        proxy_set_header   Host   \$host;\n        proxy_set_header   X-Real-IP  \$remote_addr;\n        proxy_set_header   X-Forwarded-For \$proxy_add_x_forwarded_for;\n        }\nlocation @apache {\n        internal;\n{$PROXYCONF}\n        proxy_redirect  http://{$DOMAIN}:8888   http://{$DOMAIN};\n        proxy_pass   http://{$DOMIP}:8888;\n        proxy_set_header   Host   \$host;\n        proxy_set_header   X-Real-IP  \$remote_addr;\n        proxy_set_header   X-Forwarded-For \$proxy_add_x_forwarded_for;\n        }\n{$CUSTOMINCLUDE};\n}\n";
  140.         } else {
  141.             $vhostDate.= "#################################################################\n########### Vhost configuration of  {$DOMAIN}  in Direct Proxy\n#################################################################\nserver {\naccess_log off;\nerror_log  logs/vhost-error_log warn;\nlisten    80;\nserver_name  {$DOMAIN} www.{$DOMAIN};\nlocation ~ /\\.ht {\n          deny all;\n        }\nlocation / {\n        log_not_found  off;\n{$PROXYCONF}\n        proxy_redirect  http://www.{$DOMAIN}:8888   http://www.{$DOMAIN};\n        proxy_redirect  http://{$DOMAIN}:8888   http://{$DOMAIN};\n        proxy_pass   http://{$DOMIP}:8888/;\n        proxy_set_header   Host   \$host;\n        proxy_set_header   X-Real-IP  \$remote_addr;\n        proxy_set_header   X-Forwarded-For \$proxy_add_x_forwarded_for;\n        }\n{$CUSTOMINCLUDE};\n\n}\n";
  142.         }
  143.     }
  144.     $fh = fopen("/usr/local/nginx/conf/vhost.conf", "w");
  145.     fwrite($fh, $vhostDate);
  146.     fclose($fh);
  147.     system("/etc/init.d/nginx  reload");
  148.     if ($results['localkey']) {
  149.         $localkeydata = $results['localkey'];
  150.         $cachekeyfile = "/etc/danginx/localkey.txt";
  151.         if (!($fh = fopen($cachekeyfile, "w"))) {
  152.             exit("can't open file");
  153.         }
  154.         $stringData = $localkeydata;
  155.         fwrite($fh, $stringData);
  156.         fclose($fh);
  157.     }
  158. } else if ($results['status'] == "Invalid") {
  159.     print "License  key not found. If you already have the license key, please update the key ";
  160.     $fh = fopen("/usr/local/nginx/conf/vhost.conf", "w");
  161.     fwrite($fh, "#Invalid license");
  162.     fclose($fh);
  163. } else {
  164.     if ($results['status'] == "Expired") {
  165.         print "Your License key  Expired . Please purchase the key and reactivate it.";
  166.         $fh = fopen("/usr/local/nginx/conf/vhost.conf", "w");
  167.         fwrite($fh, "#License Expired");
  168.         fclose($fh);
  169.     } else {
  170.         if ($results['status'] == "Suspended") {
  171.             print "Your License key  is Suspended. Please contact  our support team from https://portal.syslint.com/supporttickets.php";
  172.             $fh = fopen("/usr/local/nginx/conf/vhost.conf", "w");
  173.             fwrite($fh, "#License Suspended");
  174.             fclose($fh);
  175.         }
  176.     }
  177. }
  178. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement