Example #1
0
 public static function SendEmail($sTo, $sSubject, $sTemplate, $sVariable)
 {
     global $sPanelURL;
     global $sPanelMode;
     global $sTitle;
     global $locale;
     $sEmail = Templater::AdvancedParse('/email/' . $sTemplate, $locale->strings, array("EmailVars" => array("entry" => $sVariable)));
     $sMail = Core::GetSetting('mail');
     $sMail = $sMail->sValue;
     if ($sMail == 1) {
         $sSendGridUser = Core::GetSetting('mail_username');
         $sSendGridPass = Core::GetSetting('mail_password');
         $sSendGridUser = $sSendGridUser->sValue;
         $sSendGridPass = $sSendGridPass->sValue;
         if (!empty($sSendGridUser) && !empty($sSendGridPass)) {
             $sGrid = new SendGrid($sSendGridUser, $sSendGridPass);
             $sMail = new SendGrid\Mail();
             $sMail->addTo($sTo)->setFrom("noreply@{$sPanelURL->sValue}")->setSubject($sSubject)->setHtml($sEmail);
             $sGrid->web->send($sMail);
             return true;
         } else {
             return $sReturn = array("content" => "Unfortunately Send Grid is incorrectly configured!");
         }
     } elseif ($sMail == 2) {
         $sMandrillUser = Core::GetSetting('mail_username');
         $sMandrillPass = Core::GetSetting('mail_password');
         $sMandrillUser = $sMandrillUser->sValue;
         $sMandrillPass = $sMandrillPass->sValue;
         try {
             $sMandrill = new Mandrill($sMandrillPass);
             $sMessage = array('html' => $sEmail, 'subject' => $sSubject, 'from_email' => "noreply@{$sPanelURL->sValue}", 'from_name' => "{$sTitle->sValue}", 'to' => array(array('email' => $sTo, 'type' => 'to')), 'important' => true, 'track_opens' => null, 'track_clicks' => null, 'auto_text' => null, 'auto_html' => null, 'inline_css' => null, 'url_strip_qs' => null, 'preserve_recipients' => null, 'view_content_link' => null, 'tracking_domain' => null, 'signing_domain' => null, 'return_path_domain' => null, 'merge' => true);
             $sAsync = false;
             $sIPPool = 'Main Pool';
             $sSendAt = NULL;
             $sResult = $sMandrill->messages->send($sMessage, $sAsync, $sIPPool, $sSendAt);
         } catch (Exception $e) {
             return $sReturn = array("content" => "Mandril Error: {$e}");
         }
         return true;
     } else {
         $sHeaders = "MIME-Version: 1.0" . "\r\n";
         $sHeaders .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
         $sHeaders .= 'From: <noreply@' . $sPanelURL->sValue . '>' . "\r\n";
         if (mail($sTo, $sSubject, $sEmail, $sHeaders)) {
             return true;
         } else {
             return $sReturn = array("content" => "Unfortunatly the email failed to send, please check your server's sendmail settings.");
         }
     }
 }
Example #2
0
 public function Render()
 {
     global $locale;
     switch ($this->sErrorType) {
         case CPHP_ERRORHANDLER_TYPE_ERROR:
             $template = "errorhandler.error";
             break;
         case CPHP_ERRORHANDLER_TYPE_INFO:
             $template = "errorhandler.info";
             break;
         case CPHP_ERRORHANDLER_TYPE_WARNING:
             $template = "errorhandler.warning";
             break;
         case CPHP_ERRORHANDLER_TYPE_SUCCESS:
             $template = "errorhandler.success";
             break;
         default:
             return false;
     }
     return Templater::AdvancedParse($template, $locale->strings, array('title' => $this->sTitle, 'message' => $this->sMessage));
 }
Example #3
0
File: help.php Project: deanet/Neon
<?php

include './includes/loader.php';
if ($LoggedIn === false) {
    header("Location: index.php");
    die;
} else {
    $sContent = Templater::AdvancedParse('/blue_default/help', $locale->strings, array('ErrorMessage' => ""));
    echo Templater::AdvancedParse('/blue_default/master', $locale->strings, array('PageTitle' => "Help & Information", 'PageName' => "help", 'ErrorMessage' => "", 'Content' => $sContent));
}
Example #4
0
<?php

if ($sUser->sPermissions != 7) {
    die("Sorry you've accessed our system without permission");
}
$sPage = "addserver";
$sPageType = "servers";
if ($sAction == submitserver) {
    $sAddServer = Server::server_add($_POST['name'], $_POST['hostname'], $_POST['username'], $_POST['key'], $_POST['type'], $_POST['status'], $_POST['location'], $_POST['qemu'], $_POST['volume_group']);
    if (is_array($sAddServer)) {
        $sErrors[] = $sAddServer;
    }
}
$sContent = Templater::AdvancedParse($sAdminTemplate->sValue . '/addserver', $locale->strings, array("Errors" => $sErrors));
Example #5
0
    die;
}
if ($sAction == create) {
    if (is_numeric($sRequested["POST"]["server"])) {
        $sServer = new Server($sRequested["POST"]["server"]);
        $sServerType = new $sServer->sType();
        $sMethod = "database_{$sServer->sType}_create";
        $sSecond = "{$sServer->sType}_create";
        $sCreate = $sServerType->{$sMethod}($sUser, $sRequested);
        if (is_array($sCreate)) {
            echo json_encode($sCreate);
            die;
        }
        $sFinish = $sServerType->{$sSecond}($sUser, $sRequested);
        if (is_array($sFinish)) {
            echo json_encode($sFinish);
            die;
        }
    }
}
$sUsers = $database->CachedQuery("SELECT * FROM accounts ORDER BY `email_address` ASC", array());
foreach ($sUsers->data as $value) {
    $sUserList[] = array("id" => $value["id"], "email" => $value["email_address"]);
}
if ($sServers = $database->CachedQuery("SELECT * FROM servers", array())) {
    foreach ($sServers->data as $value) {
        $sServerList[] = array("id" => $value["id"], "name" => $value["name"], "type" => $value["type"]);
    }
}
$sContent = Templater::AdvancedParse($sAdminTemplate->sValue . '/createvps', $locale->strings, array('UserList' => $sUserList, 'ServerList' => $sServerList));
Example #6
0
 public function kvm_statistics($sUser, $sVPS, $sRequested)
 {
     global $sTemplate;
     global $database;
     global $locale;
     $sServer = new Server($sVPS->sServerId);
     $sSSH = Server::server_connect($sServer);
     $sLog[] = array("command" => "virsh list | grep kvm{$sVPS->sContainerId}", "result" => $sSSH->exec("virsh list | grep kvm{$sVPS->sContainerId}"));
     if ($sTemplates = $database->CachedQuery("SELECT * FROM templates WHERE `id` = :TemplateId", array('TemplateId' => $sVPS->sTemplateId))) {
         $sVPSTemplate = new Template($sVPS->sTemplateId);
         $sTemplateName = $sVPSTemplate->sName;
     } else {
         $sTemplateName = "N/A";
     }
     if ($sVPS->sBandwidthUsage > 0) {
         $sBandwidthUsage = FormatBytes($sVPS->sBandwidthUsage, 0);
     } else {
         $sBandwidthUsage = "0 KB";
     }
     $sPercentBandwidth = round(100 / ($sVPS->sBandwidthLimit * 1024 * 1024) * $sVPS->sBandwidthUsage, 0);
     if (empty($sPercentBandwidth)) {
         $sPercentBandwidth = 0;
     }
     $sMac = explode(",", $sVPS->sMac);
     $sIPList = VPS::list_ipspace($sVPS);
     $sStatistics = array("info" => array("ram" => $sVPS->sRAM, "disk" => $sVPS->sDisk, "cpulimit" => $sVPS->sCPULimit, "bandwidth_usage" => $sBandwidthUsage, "bandwidth_limit" => FormatBytes($sVPS->sBandwidthLimit * 1024, 0), "percent_bandwidth" => round(100 / ($sVPS->sBandwidthLimit * 1024) * $sVPS->sBandwidthUsage, 0), "template" => $sTemplateName, "hostname" => $sVPS->sHostname, "primary_ip" => $sVPS->sPrimaryIP, "gateway" => $sIPList[0]["gateway"], "netmask" => $sIPList[0]["netmask"], "mac" => $sMac[0]));
     $sStatistics = Templater::AdvancedParse($sTemplate->sValue . '/' . $sVPS->sType . '.statistics', $locale->strings, array("Statistics" => $sStatistics));
     if (strpos($sLog[0]["result"], 'running') === false) {
         return $sArray = array("json" => 1, "type" => "status", "result" => "offline", "hostname" => $sVPS->sHostname, "content" => $sStatistics);
     } else {
         return $sArray = array("json" => 1, "type" => "status", "result" => "online", "hostname" => $sVPS->sHostname, "content" => $sStatistics);
     }
 }
Example #7
0
<?php

include './includes/loader.php';
$sId = $_GET['id'];
$sView = $_GET['view'];
$sAction = $_GET['action'];
$sSearch = $_GET['search'];
$sType = $_GET['type'];
$sPage = "admin";
$sPageType = "";
if (empty($sUser)) {
    header("Location: index.php");
    die;
}
if ($sUser->sPermissions != 7) {
    header("Location: main.php");
    die;
}
if (file_exists('./admin/' . $sView . '.php')) {
    include './admin/' . $sView . '.php';
} else {
    include "./admin/dashboard.php";
}
echo Templater::AdvancedParse($sTemplate->sValue . '/master', $locale->strings, array("Content" => $sContent, "Page" => $sPage, "PageType" => $sPageType, "Errors" => $sErrors));
Example #8
0
<?php

if ($sUser->sPermissions != 7) {
    die("Sorry you've accessed our system without permission");
}
$sPage = "adduser";
$sPageType = "users";
if ($sAction == submituser) {
    $sCreate = User::generate_user($_POST['email'], $_POST['username']);
    echo json_encode($sCreate);
    die;
}
$sContent = Templater::AdvancedParse($sAdminTemplate->sValue . '/adduser', $locale->strings, array());
Example #9
0
<?php

if ($sUser->sPermissions != 7) {
    die("Sorry you've accessed our system without permission");
}
$sPage = "ippools";
$sPageType = "settings";
$uType = $_GET['type'];
$uPool = $_GET['pool'];
$uAction = $_GET['action'];
if (isset($uAction)) {
    $sResult = Block::$uAction($sRequested);
    if (is_array($sResult)) {
        echo json_encode($sResult);
        die;
    }
}
if (!isset($uType)) {
    $sContent .= Templater::AdvancedParse($sAdminTemplate->sValue . '/ippools', $locale->strings, array());
} else {
    if (isset($uPool)) {
        $sData = Block::list_pool($uType, $uPool);
        $sContent .= Templater::AdvancedParse($sAdminTemplate->sValue . '/ippools', $locale->strings, array("Type" => $uType, "Pool" => $uPool, "IPList" => $sData["IPList"], "ServerList" => $sData["ServerList"], "AvailableServers" => $sData["AvailableServers"], "BlockName" => $sData["BlockName"]));
    } else {
        $sBlockList = Block::block_list($sType);
        $sContent .= Templater::AdvancedParse($sAdminTemplate->sValue . '/ippools', $locale->strings, array("Type" => $uType, "BlockList" => $sBlockList));
    }
}
 public function openvz_statistics($sUser, $sVPS, $sRequested)
 {
     global $sTemplate;
     global $database;
     global $locale;
     $sServer = new Server($sVPS->sServerId);
     $sSSH = Server::server_connect($sServer);
     $sLog[] = array("command" => "vzctl status {$sVPS->sContainerId}", "result" => $sSSH->exec("vzctl status {$sVPS->sContainerId}"));
     if (strpos($sLog[0]["result"], 'running') === false) {
         return $sArray = array("json" => 1, "type" => "status", "result" => "offline", "hostname" => $sVPS->sHostname);
     } else {
         $sUptime = explode(' ', $sSSH->exec("vzctl exec {$sVPS->sContainerId} cat /proc/uptime"));
         $sRAM = explode('kB', $sSSH->exec("vzctl exec {$sVPS->sContainerId} cat /proc/meminfo"));
         $sUsedRAM = preg_replace("/[^0-9]/", "", $sRAM[0]) - preg_replace("/[^0-9]/", "", $sRAM[1]);
         $sTotalRAM = preg_replace("/[^0-9]/", "", $sRAM[0]);
         $sUsedSWAP = preg_replace("/[^0-9]/", "", $sRAM[11]) - preg_replace("/[^0-9]/", "", $sRAM[12]);
         if ($sUsedSWAP < 0) {
             $sUsedSWAP = preg_replace("/[^0-9]/", "", $sRAM[12]) - preg_replace("/[^0-9]/", "", $sRAM[13]);
         }
         $sTotalSWAP = $sVPS->sSWAP;
         $sDisk = $sSSH->exec("vzctl exec {$sVPS->sContainerId} df");
         $sDisk = explode("\n", trim($sDisk));
         array_shift($sDisk);
         foreach ($sDisk as $sValue) {
             $sValue = explode(" ", preg_replace("/\\s+/", " ", $sValue));
             if (is_numeric($sValue[2])) {
                 $sDiskUsed = $sDiskUsed + $sValue[2];
             }
         }
         $sDiskUsed = $sDiskUsed / 1048576;
         $sDiskTotal = $sVPS->sDisk;
         $sCPU = explode(' ', $sSSH->exec("vzctl exec {$sVPS->sContainerId} cat /proc/loadavg"));
         if ($sUsedRAM > 0) {
             $sUsedRAM = round($sUsedRAM / 1024, 0);
         }
         if ($sTotalRAM > 0) {
             $sTotalRAM = round($sTotalRAM / 1024, 0);
         }
         if ($sUsedRAM > 0 && $sTotalRAM > 0) {
             $sPercentRAM = round(100 / $sTotalRAM * $sUsedRAM, 0);
         } else {
             $sPercentRAM = 0;
         }
         if ($sUsedSWAP > 0) {
             $sUsedSWAP = round($sUsedSWAP / 1024, 0);
         }
         if ($sUsedSWAP > 0 && $sTotalSWAP > 0) {
             $sPercentSWAP = round(100 / $sTotalSWAP * $sUsedSWAP, 0);
         } else {
             $sPercentSWAP = 0;
         }
         if ($sDiskUsed > 0 && $sDiskTotal > 0) {
             $sPercentDisk = round(100 / $sDiskTotal * $sDiskUsed, 0);
         } else {
             $sPercentDisk = 0;
         }
         if ($sCPU[0] > 0 && $sVPS->sCPULimit > 0) {
             $sPercentCPU = round(100 / $sVPS->sCPULimit * ($sCPU[0] * 100), 0);
         } else {
             $sPercentCPU = 0;
         }
         if ($sVPS->sCPULimit > 0) {
             $sCores = round($sVPS->sCPULimit / 100, 0);
         } else {
             $sCores = 0;
         }
         if ($sDiskUsed < 1) {
             $sDiskUsed = round($sDiskUsed, 2);
         } else {
             $sDiskUsed = round($sDiskUsed, 0);
         }
         if ($sTemplates = $database->CachedQuery("SELECT * FROM templates WHERE `id` = :TemplateId", array('TemplateId' => $sVPS->sTemplateId))) {
             $sVPSTemplate = new Template($sVPS->sTemplateId);
             $sTemplateName = $sVPSTemplate->sName;
         } else {
             $sTemplateName = "N/A";
         }
         if ($sVPS->sBandwidthUsage > 0) {
             $sBandwidthUsage = FormatBytes($sVPS->sBandwidthUsage, 2);
         } else {
             $sBandwidthUsage = "0 MB";
         }
         if (!empty($sVPS->sBandwidthLimit) && !empty($sVPS->sBandwidthUsage)) {
             $sPercentBandwidth = round(100 / ($sVPS->sBandwidthLimit * 1024) * $sVPS->sBandwidthUsage, 0);
             if (empty($sPercentBandwidth)) {
                 $sPercentBandwidth = 0;
             }
         } else {
             $sPercentBandwidth = 0;
         }
         $sStatistics = array("info" => array("uptime" => ConvertTime($sUptime[0]), "used_ram" => $sUsedRAM, "total_ram" => $sTotalRAM, "percent_ram" => $sPercentRAM, "used_swap" => $sUsedSWAP, "total_swap" => $sTotalSWAP, "percent_swap" => $sPercentSWAP, "used_disk" => $sDiskUsed, "total_disk" => round($sDiskTotal, 0), "percent_disk" => $sPercentDisk, "total_cpu" => $sVPS->sCPULimit, "total_cores" => $sCores, "used_cores" => $sCPU[0], "used_cpu" => $sCPU[0] * 100, "percent_cpu" => $sPercentCPU, "load_average" => "{$sCPU['0']} {$sCPU['1']} {$sCPU['2']}", "bandwidth_usage" => $sBandwidthUsage, "bandwidth_limit" => FormatBytes($sVPS->sBandwidthLimit * 1024, 0), "percent_bandwidth" => round(100 / ($sVPS->sBandwidthLimit * 1024) * $sVPS->sBandwidthUsage, 0), "operating_system" => $sTemplateName, "hostname" => $sVPS->sHostname, "primary_ip" => $sVPS->sPrimaryIP));
         $sStatistics = Templater::AdvancedParse($sTemplate->sValue . '/' . $sVPS->sType . '.statistics', $locale->strings, array("Statistics" => $sStatistics));
         return $sArray = array("json" => 1, "type" => "status", "result" => "online", "content" => $sStatistics, "hostname" => $sVPS->sHostname);
     }
 }
Example #11
0
    }
}
if (!empty($sServerVPS)) {
    foreach ($sServerVPS as $data) {
        if (!empty($data)) {
            foreach ($data as $value) {
                $sTempUser = new User($value["user_id"]);
                $sResult[] = array("result_type" => "vps", "id" => $value["id"], "user_id" => $value["user_id"], "username" => $sTempUser->sUsername, "server_id" => $value["server_id"], "hostname" => $value["hostname"], "primary_ip" => $value["primary_ip"], "type" => $value["type"], "suspended" => $value["suspended"]);
                $sVPSCount++;
            }
        }
    }
}
if (!empty($sUsers)) {
    foreach ($sUsers->data as $value) {
        $sResult[] = array("result_type" => "user", "id" => $value["id"], "username" => $value["username"], "email_address" => $value["email_address"]);
        $sUserCount++;
    }
}
if (!empty($sUserVPS)) {
    foreach ($sUserVPS as $data) {
        if (!empty($data)) {
            foreach ($data as $value) {
                $sResult[] = array("result_type" => "vps", "id" => $value["id"], "user_id" => $value["user_id"], "server_id" => $value["server_id"], "hostname" => $value["hostname"], "primary_ip" => $value["primary_ip"], "type" => $value["type"], "suspended" => $value["suspended"]);
                $sUserCount++;
            }
        }
    }
}
$sContent = Templater::AdvancedParse($sAdminTemplate->sValue . '/list', $locale->strings, array("Result" => $sResult, "ServerCount" => $sServerCount, "VPSCount" => $sVPSCount, "UserCount" => $sUserCount));
Example #12
0
File: main.php Project: deanet/Neon
            $result = $database->CachedQuery("REVOKE ALL PRIVILEGES, GRANT OPTION FROM :Username", array(':Username' => $sUser->sUsername), 1);
        }
        $sInitialSetupContent = Templater::AdvancedParse('/blue_default/setup', $locale->strings, array('PanelTitle' => $sPanelTitle->sValue, 'ErrorMessage' => "", 'Username' => $sUser->sUsername, 'InitialSetup' => $sUser->sInitialSetup));
    } else {
        $sInitialSetupContent = "";
    }
    $sUsedMemory = $database->CachedQuery("SELECT * FROM stats WHERE type='used_memory' ORDER BY id DESC LIMIT 60", array(), 1);
    foreach ($sUsedMemory->data as $key => $value) {
        $sUsed[] = $value["result"];
    }
    $sTotalMemory = $database->CachedQuery("SELECT * FROM stats WHERE type='total_memory' ORDER BY id DESC LIMIT 60", array(), 1);
    foreach ($sTotalMemory->data as $key => $value) {
        $sTotal[] = $value["result"];
    }
    $sRAMUsage[] = array("name" => "60", "used" => round($sUsed[59] / 1024), "total" => round($sTotal[59] / 1024));
    $sRAMUsage[] = array("name" => "30", "used" => round($sUsed[29] / 1024), "total" => round($sTotal[29] / 1024));
    $sRAMUsage[] = array("name" => "15", "used" => round($sUsed[14] / 1024), "total" => round($sTotal[14] / 1024));
    $sRAMUsage[] = array("name" => "5", "used" => round($sUsed[4] / 1024), "total" => round($sTotal[4] / 1024));
    $sRAMUsage[] = array("name" => "1", "used" => round($sUsed[0] / 1024), "total" => round($sTotal[0] / 1024));
    $sLoadAverage = $database->CachedQuery("SELECT * FROM stats WHERE type='load' ORDER BY id DESC LIMIT 60", array(), 1);
    foreach ($sLoadAverage->data as $key => $value) {
        $sLoads[] = $value["result"];
    }
    $sLoad[] = array("name" => 60, "AVG" => check_set($sLoads[59]));
    $sLoad[] = array("name" => 30, "AVG" => check_set($sLoads[29]));
    $sLoad[] = array("name" => 15, "AVG" => check_set($sLoads[14]));
    $sLoad[] = array("name" => 5, "AVG" => check_set($sLoads[4]));
    $sLoad[] = array("name" => 1, "AVG" => $sLoads[0]);
    $sContent = Templater::AdvancedParse('/blue_default/main', $locale->strings, array('ErrorMessage' => "", 'InitialSetup' => $sUser->sInitialSetup, 'WelcomeClosed' => $sUser->sWelcomeClosed, 'InitialSetupContent' => $sInitialSetupContent, 'Load' => $sLoad, 'RAM' => $sRAMUsage));
    echo Templater::AdvancedParse('/blue_default/master', $locale->strings, array('PageTitle' => "Main Dashboard", 'PageName' => "main", 'ErrorMessage' => "", 'Content' => $sContent));
}
Example #13
0
<?php

include './includes/loader.php';
$sAction = $_GET['action'];
if (empty($_GET['email']) || empty($_GET['id'])) {
    header("Location: index.php");
    die;
}
$sActivate = $database->CachedQuery("SELECT * FROM accounts WHERE (`password` = -1 AND `email_address` = :EmailAddress AND `activation_code` = :ActivationCode) || (`email_address` = :EmailAddress AND `forgot` = :ActivationCode)", array('EmailAddress' => $_GET['email'], 'ActivationCode' => $_GET['id']));
if (empty($sActivate)) {
    header("Location: index.php");
    die;
}
if ($sAction == save) {
    $sUser = new User($sActivate->data[0]["id"]);
    $sChange = $sUser->change_password($sUser, $_POST['password'], $_POST['passwordagain']);
    if (is_array($sChange)) {
        $sErrors = array("Errors" => $sChange);
    } else {
        header("Location: index.php");
        die;
    }
}
echo Templater::AdvancedParse($sTemplate->sValue . '/activate', $locale->strings, array('Errors' => $sErrors, 'Id' => urlencode($_GET['id']), 'Email' => urlencode($_GET['email'])));
Example #14
0
    if (!empty($_GET['id'])) {
        $sRemove = VPS::remove_template(VPS::localhost_connect(), $_GET['id']);
        if (is_array($sRemove)) {
            echo json_encode($sRemove);
            die;
        }
    }
    $sJson = 1;
}
if ($sAction == updatetemplate) {
    if (!empty($_GET['name']) && is_numeric($_GET['id'])) {
        $sUpdateTemplate = new Template($_GET['id']);
        $sUpdateTemplate->uName = $_GET['name'];
        $sUpdateTemplate->InsertIntoDatabase();
        echo json_encode(array("result" => "Template name updated.", "type" => "success", "json" => "1"));
        die;
    } else {
        echo json_encode(array("result" => "You must specify a name for the template.", "type" => "error", "json" => "1"));
        die;
    }
}
if (empty($sType)) {
    $sContent .= Templater::AdvancedParse($sAdminTemplate->sValue . '/templates', $locale->strings, array("Virtualization" => 0));
} else {
    if ($sTL = $database->CachedQuery("SELECT * FROM templates WHERE `type` = :Type", array('Type' => $sType))) {
        foreach ($sTL->data as $sData) {
            $sTemplateList[] = array("id" => $sData["id"], "name" => $sData["name"], "path" => $sData["path"]);
        }
    }
    $sContent .= Templater::AdvancedParse($sAdminTemplate->sValue . '/templates', $locale->strings, array("Virtualization" => $sType, "TemplateList" => $sTemplateList, "Errors" => $sErrors));
}
Example #15
0
    header("Location: index.php");
    die;
} else {
    if (!empty($_GET['format'])) {
        $sFormat = $_GET['format'];
    }
    if (!empty($_GET['action'])) {
        $sAction = $_GET['action'];
    }
    if ($sAction == adddomain) {
        $return = Domain::AddDomain($_GET['name']);
    }
    if ($sAction == removedomain) {
        $return = Domain::RemoveDomain($_GET['name']);
    }
    $sUserDomains = $database->CachedQuery("SELECT * FROM domains WHERE `user_id` = :UserId ", array(':UserId' => $sUser->sId), 1);
    if (!empty($sUserDomains)) {
        foreach ($sUserDomains->data as $key => $value) {
            $sDomains[] = array("id" => $value["id"], "domain" => $value["domain_name"]);
        }
    }
    $sDomainManager = Templater::AdvancedParse('/blue_default/domainmanager', $locale->strings, array('ErrorMessage' => "", 'Domains' => $sDomains));
    if (!isset($sFormat)) {
        $sContent = Templater::AdvancedParse('/blue_default/domains', $locale->strings, array('ErrorMessage' => "", 'DomainManagerCode' => $sDomainManager));
        echo Templater::AdvancedParse('/blue_default/master', $locale->strings, array('PageTitle' => "Domain Manager", 'PageName' => "domainmanager", 'ErrorMessage' => "", 'Content' => $sContent));
    } else {
        $sContent = preg_replace('/\\r\\n|\\r|\\n/', '', $sDomainManager);
        $sReturnArray = array("content" => $sContent);
        echo json_encode($sReturnArray);
    }
}
Example #16
0
if (!empty($sAction)) {
    set_time_limit(100);
    $sStart = new $sVPS->sType();
    $sDBAction = "database_{$sVPS->sType}_{$sAction}";
    $sServerAction = "{$sVPS->sType}_{$sAction}";
    if (method_exists($sStart, $sDBAction) === true && method_exists($sStart, $sServerAction) === true) {
        $sDBResult = $sStart->{$sDBAction}($sUser, $sVPS, $sRequested);
        if (is_array($sDBResult)) {
            echo json_encode($sDBResult);
            die;
        }
        $sServerResult = $sStart->{$sServerAction}($sUser, $sVPS, $sRequested);
        if (!empty($sServerResult["json"])) {
            echo json_encode($sServerResult);
            die;
        }
    } else {
        echo json_encode(array("json" => 1, "type" => "error", "result" => "Invalid action requested. Please try again.", "reload" => 1));
        die;
    }
}
// Check to make sure VPS isn't rebuilding.
if ($sVPS->sRebuilding == 1) {
    $sUserView .= Templater::AdvancedParse($sTemplate->sValue . '/rebuild', $locale->strings, array("VPS" => array("data" => $sVPS->uData)));
    echo Templater::AdvancedParse($sTemplate->sValue . '/master', $locale->strings, array("Content" => $sUserView, "Page" => "main"));
    die;
}
$sVPSOwner = new User($sVPS->sUserId);
$sUserView .= Templater::AdvancedParse($sTemplate->sValue . '/' . $sVPS->sType . '.view', $locale->strings, array("VPS" => array("data" => $sVPS->uData), "IPs" => VPS::list_ipspace($sVPS), "Templates" => VPS::list_templates($sVPS), "Servers" => VPS::list_servers($sVPS), "User" => array("data" => $sVPSOwner->uData), "UserVPSList" => VPS::list_uservps($sVPS)));
echo Templater::AdvancedParse($sTemplate->sValue . '/master', $locale->strings, array("Content" => $sUserView, "Page" => "main"));
die;
Example #17
0
                if ($sIPList = $database->CachedQuery("SELECT * FROM `ipaddresses` WHERE `block_id` = :BlockId AND `vps_id` = :VPSId", array("BlockId" => $sBlockRow["block_id"], "VPSId" => 0))) {
                    $sIPCount = $sIPCount + count($sIPList->data);
                }
            }
        } else {
            $sIPCount = "0";
        }
        $sStatistics[] = array("name" => $sServer->sName, "load_average" => $sServer->sLoadAverage, "disk_usage" => $sHardDiskUsed, "disk_free" => $sHardDiskFree, "ram_usage" => $sRAMUsed, "ram_free" => $sRAMFree, "status" => $sServer->sStatus, "uptime" => ConvertTime(round($sServer->sHardwareUptime, 0)), "ip_count" => $sIPCount, "type" => $sType, "bandwidth" => $sBandwidthDifference);
        if (empty($sServer->sStatus)) {
            $sDown[] = array("name" => $sServer->sName);
        }
        // Cleanup just in case.
        unset($sHardDiskUsed);
        unset($sHardDiskFree);
        unset($sRAMUsed);
        unset($sRAMFree);
        unset($sLastCheck);
        unset($sPreviousCheck);
        unset($sBandwidth);
        unset($sLastBandwidth);
        unset($sBandwidthDifference);
        unset($sIPCount);
    }
}
$sPage = "dashboard";
$sPageType = "admin";
$sContent = Templater::AdvancedParse($sAdminTemplate->sValue . '/status', $locale->strings, array("Statistics" => $sStatistics, "Down" => $sDown, "High" => $sHigh, "Status" => $sRequested["GET"]["json"]));
if (!empty($sRequested["GET"]["json"])) {
    echo json_encode(array("content" => $sContent));
    die;
}
Example #18
0
<?php

include './includes/loader.php';
if ($LoggedIn === false) {
    header("Location: index.php");
    die;
} else {
    $sContent = Templater::AdvancedParse('/blue_default/settings', $locale->strings, array('ErrorMessage' => ""));
    echo Templater::AdvancedParse('/blue_default/master', $locale->strings, array('PageTitle' => "Server Settings", 'PageName' => "settings", 'ErrorMessage' => "", 'Content' => $sContent));
}
Example #19
0
                if ($sNumber > 0) {
                    $sNumber++;
                }
                $sDatabaseList[] = array("name" => $value["Database"], "users" => $sUsers, "number" => $sNumber);
                unset($sUsers);
                unset($sNumber);
            }
        }
        $sUsers = $database->CachedQuery("SELECT User from mysql.user", array(), 1);
        $sUserList = array();
        foreach ($sUsers->data as $key => $value) {
            if (substr($value["User"], 0, $sUsernameLength) == $sUser->sUsername . '_') {
                $sUserList[] = $value["User"];
            }
        }
        $sContent = Templater::AdvancedParse('/blue_default/mysqldatabaseusers', $locale->strings, array('PanelTitle' => $sPanelTitle->sValue, 'ErrorMessage' => "", 'DatabaseList' => $sDatabaseList, 'UserList' => $sUserList));
    } elseif ($sView == wizard) {
        $sPageTitle = "Mysql Database Wizard";
        $sContent = Templater::AdvancedParse('/blue_default/mysqlwizard', $locale->strings, array('PanelTitle' => $sPanelTitle->sValue, 'ErrorMessage' => "", 'WizardClosed' => $sUser->sWizardClosed, 'DatabaseReturn' => $sDatabaseReturn));
    } else {
        die("Unfortunatly no view was selected, thus this page can not load.");
    }
    if (!isset($sFormat)) {
        $sMysql = Templater::AdvancedParse('/blue_default/mysql', $locale->strings, array('PanelTitle' => $sPanelTitle->sValue, 'ErrorMessage' => "", 'MysqlManagerCode' => $sContent));
        echo Templater::AdvancedParse('/blue_default/master', $locale->strings, array('PageTitle' => $sPageTitle, 'PageName' => $sView, 'ErrorMessage' => "", 'Content' => $sMysql, 'MysqlPage' => 1));
    } else {
        $sContent = preg_replace('/\\r\\n|\\r|\\n/', '', $sContent);
        $sReturnArray = array("content" => $sContent);
        echo json_encode($sReturnArray);
    }
}
Example #20
0
        $sErrors[] = array("result" => "Automatic updates have been turned off.", "type" => "success");
    }
}
if ($sAction == force) {
    $sSSH = new Net_SSH2('127.0.0.1');
    $sKey = new Crypt_RSA();
    $sKey->loadKey(file_get_contents($cphp_config->settings->rootkey));
    if ($sSSH->login("root", $sKey)) {
        $sOldVersion = file_get_contents('/var/feathur/version.txt');
        $sSSH->exec("cd /var/feathur/; git reset --hard; git pull; cd /var/feathur/feathur/; php update.php; rm -rf update.php;");
        $sVersion = file_get_contents('/var/feathur/version.txt');
        $sLastUpdate = Core::UpdateSetting('last_update_check', time());
        $sCurrentVersion = file_get_contents('/var/feathur/version.txt');
        if ($sCurrentVersion != $sOldVersion) {
            $sErrors[] = array("result" => "Force update completed.", "type" => "success");
        } elseif ($sCurrentVersion->sValue == $sOldVersion->sValue) {
            $sErrors[] = array("result" => "Force update failed, no updates available.", "type" => "error");
        } else {
            $sErrors[] = array("result" => "Force update failed, unknown error.", "type" => "error");
        }
    }
    $sJson = 1;
}
$sAutomaticUpdates = Core::GetSetting('automatic_updates');
$sUpdates[] = check_updates();
$sContent .= Templater::AdvancedParse($sAdminTemplate->sValue . '/update', $locale->strings, array("AutomaticUpdates" => $sAutomaticUpdates->sValue, "Updates" => $sUpdates, "Outdated" => $sUpdates[0]["update"], "Errors" => $sErrors));
if ($sJson == 1) {
    echo json_encode(array("content" => $sContent));
    die;
}
unset($sErrors);
Example #21
0
<?php

include './includes/loader.php';
if ($sRegistrationEnabled->sValue == 'enabled') {
    if ($LoggedIn === true) {
        header("Location: main.php");
        die;
    } else {
        if (empty($_GET['id']) || $_GET['id'] == 'register') {
            if (isset($_POST['submit'])) {
                /* The form was submitted. */
                $sErrorMessage = User::register($_POST['username'], $_POST['passwordone'], $_POST['passwordtwo'], $_POST['email']);
            } else {
                $sErrorMessage = "";
            }
            $sPageContents = Templater::AdvancedParse('blue_default/register', $locale->strings, array('ErrorMessage' => $sErrorMessage));
            $sPageTitle = "Register";
        } elseif ($_GET['id'] == 'activate') {
            $sPageContents = Templater::AdvancedParse('blue_default/activate', $locale->strings, array('PanelTitle' => $sPanelTitle->sValue));
            $sPageTitle = "Activate";
        } else {
            /* TODO: create a proper template for this. */
            $sPageContents = "Page not found";
            $sPageTitle = "Not found";
        }
        echo Templater::AdvancedParse('blue_default/master.login', $locale->strings, array('PanelTitle' => $sPanelTitle->sValue, 'PageTitle' => $sPageTitle, 'contents' => $sPageContents));
    }
}
Example #22
0
<?php

include './includes/loader.php';
if (empty($sUser)) {
    header("Location: index.php");
    die;
}
if ($sUser->sPermissions == 7 && empty($_GET['force'])) {
    header("Location: admin.php");
    die;
}
$sPullVPS = $database->CachedQuery("SELECT * FROM vps WHERE `user_id` = :UserId", array('UserId' => $sUser->sId));
if (empty($sPullVPS)) {
    $sErrors[] = array("red" => "You currently do not have any VPS. Please contact our support department.");
}
$sMain = Templater::AdvancedParse($sTemplate->sValue . '/main', $locale->strings, array());
echo Templater::AdvancedParse($sTemplate->sValue . '/master', $locale->strings, array("Content" => $sMain, "Page" => "main", "Errors" => $sErrors));
Example #23
0
<?php

require_once './includes/loader.php';
$sAction = $_GET['action'];
if (!empty($sUser)) {
    header("Location: main.php");
    die;
}
if ($sAction == 'login') {
    $sErrors[] = User::login($_POST['email'], $_POST['password']);
}
echo Templater::AdvancedParse($sTemplate->sValue . '/login', $locale->strings, array("Errors" => $sErrors));
Example #24
0
File: ftp.php Project: deanet/Neon
<?php

include './includes/loader.php';
if ($LoggedIn === false) {
    header("Location: index.php");
    die;
} else {
    $sContent = Templater::AdvancedParse('/blue_default/ftp', $locale->strings, array('PanelTitle' => $sPanelTitle->sValue, 'ErrorMessage' => "", 'Username' => $sUser->sUsername));
    echo Templater::AdvancedParse('/blue_default/master', $locale->strings, array('PageTitle' => "FTP Accounts", 'PageName' => "ftp", 'PanelTitle' => $sPanelTitle->sValue, 'ErrorMessage' => "", 'Username' => $sUser->sUsername, 'Content' => $sContent));
}
Example #25
0
// Check for login.
if (empty($sUser)) {
    header("Location: index.php");
    die;
}
// Check to make sure the user is actually trying to view a vps.
if (empty($sId)) {
    header("Location: main.php");
    die;
}
// Check to make sure the vps the user is trying to view is theirs or they are a admin.
$sVPS = new VPS($sId);
if ($sVPS->sUserId != $sUser->sId && $sUser->sPermissions != 7) {
    header("Location: main.php");
    die;
}
// Restrict access to the vps if the user's vps is suspended.
if ($sVPS->sSuspended == 1 && $sUser->sPermissions != 7) {
    echo Templater::AdvancedParse($sTemplate->sValue . '/suspended', $locale->strings, array());
    die;
}
if ($sAction == connect) {
    if (!empty($_POST['hostname']) && !empty($_POST['port'])) {
        $sView = Templater::AdvancedParse($sTemplate->sValue . '/console', $locale->strings, array("connect" => "1", "VPS" => array("data" => $sVPS->uData), "Hostname" => htmlspecialchars($_POST["hostname"], ENT_QUOTES), "Port" => htmlspecialchars($_POST["port"], ENT_QUOTES)));
    } else {
        $sView = Templater::AdvancedParse($sTemplate->sValue . '/console', $locale->strings, array("connect" => "0", "VPS" => array("data" => $sVPS->uData)));
    }
} else {
    $sView = Templater::AdvancedParse($sTemplate->sValue . '/console', $locale->strings, array("connect" => "0", "VPS" => array("data" => $sVPS->uData)));
}
echo $sView;