Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include ("lib.php");
- $lines = file("/etc/danginx/data.conf");
- foreach($lines as $key) {
- $term = explode(":", trim($key));
- if ($term[0] == "LICENSE") {
- $key = $term[1];
- break;
- break;
- }
- }
- $licensekey = $key;
- $localkey = shell_exec("/bin/cat /etc/danginx/localkey.txt");
- $results = check_license($licensekey, $localkey);
- if ($results['status'] == "Active") {
- $vhostDate = "#Auto generated vhost configuration by Da Nginix. Any customization will be lost\n";
- $DBINO = array();
- $GLOBIP = "";
- if ($handle = opendir("/usr/local/directadmin/data/users")) {
- $_file_list = "";
- while (false !== ($file = readdir($handle))) {
- if ($file != "." && $file != "..") {
- $_file_list.= $file . ":";
- }
- }
- closedir($handle);
- }
- $cPuser = explode(":", $_file_list);
- sort($cPuser);
- $ArrLen = count($cPuser);
- $cpUsernumber = $ArrLen - 1;
- $i = 1;
- while ($i <= $cpUsernumber) {
- $USER = $cPuser[$i];
- $domain = file("/usr/local/directadmin/data/users/{$USER}/domains.list");
- $dom_count = count($domain);
- $j = 0;
- while ($j < $dom_count) {
- $DOMAIN = trim($domain[$j]);
- $ux = file("/usr/local/directadmin/data/users/{$USER}/user.conf");
- foreach($ux as $line_num => $line) {
- if (preg_match("/^ip=/", $line)) {
- $ipdata = explode("=", $line);
- $GLOBIP = trim($ipdata[1]);
- break;
- break;
- }
- }
- if (file_exists("/usr/local/directadmin/data/users/{$USER}/domains/{$DOMAIN}.conf")) {
- $uf = file("/usr/local/directadmin/data/users/{$USER}/domains/{$DOMAIN}.conf");
- foreach($uf as $line_num => $line) {
- if (preg_match("/^ip=/", $line)) {
- $ipdata = explode("=", $line);
- $DOMIP = trim($ipdata[1]);
- break;
- }
- $DOMIP = $GLOBIP;
- }
- $DOMDOCROOT = "/home/{$USER}/domains/{$DOMAIN}/public_html";
- $ACCESSLOG = "/var/log/httpd/domains/{$DOMAIN}.log";
- }
- if (file_exists("/etc/danginx/expires/{$DOMAIN}") && filesize("/etc/danginx/expires/{$DOMAIN}") != 0) {
- $exp_line = file("/etc/danginx/expires/{$DOMAIN}");
- $EXPIRE = trim($exp_line[0]);
- } else {
- $EXPIRE = "24h";
- }
- if (file_exists("/etc/danginx/custom/{$DOMAIN}") && filesize("/etc/danginx/custom/{$DOMAIN}") != 0) {
- $CUSTOM = "include \"/etc/danginx/custom/" . $DOMAIN . "\"";
- } else {
- $CUSTOM = "#include \"/etc/danginx/custom/" . $DOMAIN . "\"";
- }
- $fval = "{$DOMAIN}" . "|" . "{$DOMIP}" . "|" . "{$DOMDOCROOT}" . "|" . "{$ACCESSLOG}" . "|" . "{$EXPIRE}" . "|" . "{$CUSTOM}";
- $DBINO[] = $fval;
- $POINTERFILE = "/usr/local/directadmin/data/users/{$USER}/domains/{$DOMAIN}.pointers";
- if (file_exists($POINTERFILE) && filesize("{$POINTERFILE}") != 0) {
- $PDOMAIN = array();
- $pfile = file($POINTERFILE);
- foreach($pfile as $line_num => $line) {
- $tmx = explode("=alias", $line);
- $PDOMAIN[$line_num] = trim($tmx[0]);
- }
- foreach($PDOMAIN as $XDOMAIN) {
- $fval = "{$XDOMAIN}" . "|" . "{$DOMIP}" . "|" . "{$DOMDOCROOT}" . "|" . "{$ACCESSLOG}" . "|" . "{$EXPIRE}" . "|" . "{$CUSTOM}";
- $DBINO[] = $fval;
- }
- }
- if (file_exists("/usr/local/directadmin/data/users/{$USER}/domains/{$DOMAIN}.subdomains")) {
- $subdomain = file("/usr/local/directadmin/data/users/{$USER}/domains/{$DOMAIN}.subdomains");
- $subdom_count = count($subdomain);
- if (0 < $subdom_count) {
- $k = 0;
- while ($k < $subdom_count) {
- $sub = trim($subdomain[$k]);
- $SUBDOMAIN = "{$sub}" . "." . "{$DOMAIN}";
- $SUBDOCROOT = "/home/{$USER}/domains/{$DOMAIN}/public_html/{$sub}";
- $SUBACCESSLOG = "/var/log/httpd/domains/{$DOMAIN}.{$sub}.log";
- if (file_exists("/etc/danginx/expires/{$SUBDOMAIN}") && filesize("/etc/danginx/expires/{$SUBDOMAIN}") != 0) {
- $exp_line = file("/etc/danginx/expires/{$SUBDOMAIN}");
- $EXPIRE = trim($exp_line[0]);
- } else {
- $EXPIRE = "24h";
- }
- if (file_exists("/etc/danginx/custom/{$SUBDOMAIN}") && filesize("/etc/danginx/custom/{$SUBDOMAIN}") != 0) {
- $CUSTOM = "include \"/etc/danginx/custom/" . $SUBDOMAIN . "\"";
- } else {
- $CUSTOM = "#include \"/etc/danginx/custom/" . $SUBDOMAIN . "\"";
- }
- $fval = "{$SUBDOMAIN}" . "|" . "{$DOMIP}" . "|" . "{$SUBDOCROOT}" . "|" . "{$SUBACCESSLOG}" . "|" . "{$EXPIRE}" . "|" . "{$CUSTOM}";
- $DBINO[] = $fval;
- ++$k;
- }
- }
- }
- ++$j;
- }
- ++$i;
- }
- $vhlines = file("/etc/danginx/vhost.conf");
- $PROXYCONF = "\n";
- foreach($vhlines as $key) {
- $PROXYCONF.= " " . $key;
- }
- $linesext = file("/etc/danginx/fileextensions.txt");
- foreach($linesext as $key) {
- if (preg_match("/\\|/", $key)) {
- $file_est = trim($key);
- }
- }
- foreach($DBINO as $DB) {
- $tmpar = explode("|", $DB);
- $DOMAIN = $tmpar[0];
- $DOMIP = $tmpar[1];
- $DOMDOCROOT = $tmpar[2];
- $ACCESSLOG = $tmpar[3];
- $EXPIRETIME = $tmpar[4];
- $CUSTOMINCLUDE = $tmpar[5];
- if (!file_exists("/etc/danginx/direct/{$DOMAIN}")) {
- $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";
- } else {
- $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";
- }
- }
- $fh = fopen("/usr/local/nginx/conf/vhost.conf", "w");
- fwrite($fh, $vhostDate);
- fclose($fh);
- system("/etc/init.d/nginx reload");
- if ($results['localkey']) {
- $localkeydata = $results['localkey'];
- $cachekeyfile = "/etc/danginx/localkey.txt";
- if (!($fh = fopen($cachekeyfile, "w"))) {
- exit("can't open file");
- }
- $stringData = $localkeydata;
- fwrite($fh, $stringData);
- fclose($fh);
- }
- } else if ($results['status'] == "Invalid") {
- print "License key not found. If you already have the license key, please update the key ";
- $fh = fopen("/usr/local/nginx/conf/vhost.conf", "w");
- fwrite($fh, "#Invalid license");
- fclose($fh);
- } else {
- if ($results['status'] == "Expired") {
- print "Your License key Expired . Please purchase the key and reactivate it.";
- $fh = fopen("/usr/local/nginx/conf/vhost.conf", "w");
- fwrite($fh, "#License Expired");
- fclose($fh);
- } else {
- if ($results['status'] == "Suspended") {
- print "Your License key is Suspended. Please contact our support team from https://portal.syslint.com/supporttickets.php";
- $fh = fopen("/usr/local/nginx/conf/vhost.conf", "w");
- fwrite($fh, "#License Suspended");
- fclose($fh);
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement