Example #1
0
/**
 *
 * @ WHMCS FULL DECODED & NULLED
 *
 * @ Version  : 5.2.15
 * @ Author   : MTIMER
 * @ Release on : 2013-12-24
 * @ Website  : http://www.mtimer.cn
 *
 * */
function widget_staffboard_overview($vars)
{
    global $_ADMINLANG;
    $title = "Staff Noticeboard";
    $lastviews = get_query_val("tbladdonmodules", "value", array("module" => "staffboard", "setting" => "lastviewed"));
    if ($lastviews) {
        $lastviews = unserialize($lastviews);
        $new = false;
    } else {
        $lastviews = array();
        $new = true;
    }
    $lastviewed = $lastviews[$_SESSION['adminid']];
    $lastviews[$_SESSION['adminid']] = time();
    if ($new) {
        insert_query("tbladdonmodules", array("module" => "staffboard", "setting" => "lastviewed", "value" => serialize($lastviews)));
    } else {
        update_query("tbladdonmodules", array("value" => serialize($lastviews)), array("module" => "staffboard", "setting" => "lastviewed"));
    }
    $numchanged = get_query_val("mod_staffboard", "COUNT(id)", "date>='" . date("Y-m-d H:i:s", $lastviewed) . "'");
    $content = "\n<style>\n.staffboardchanges {\n    margin: 0 0 5px 0;\n    padding: 8px 25px;\n    font-size: 1.2em;\n    text-align: center;\n}\n.staffboardnotices {\n    max-height: 130px;\n    overflow: auto;\n    border-top: 1px solid #ccc;\n    border-bottom: 1px solid #ccc;\n}\n.staffboardnotices div {\n    padding: 5px 15px;\n    border-bottom: 2px solid #fff;\n}\n.staffboardnotices div.pink {\n    background-color: #F3CBF3;\n}\n.staffboardnotices div.yellow {\n    background-color: #FFFFC1;\n}\n.staffboardnotices div.purple {\n    background-color: #DCD7FE;\n}\n.staffboardnotices div.white {\n    background-color: #FAFAFA;\n}\n.staffboardnotices div.pink {\n    background-color: #F3CBF3;\n}\n.staffboardnotices div.blue {\n    background-color: #A6E3FC;\n}\n.staffboardnotices div.green {\n    background-color: #A5F88B;\n}\n</style>\n<div class=\"staffboardchanges\">There are <strong>" . $numchanged . "</strong> New or Updated Staff Notices Since your Last Visit - <a href=\"addonmodules.php?module=staffboard\">Visit Noticeboard &raquo;</a></div><div class=\"staffboardnotices\">";
    $result = select_query("mod_staffboard", "", "", "date", "DESC");
    while ($data = mysql_fetch_array($result)) {
        $content .= "<div class=\"" . $data['color'] . "\">" . fromMySQLDate($data['date'], 1) . " - " . (100 < strlen($data['note']) ? substr($data['note'], 0, 100) . "..." : $data['note']) . "</div>";
    }
    $content .= "</div>";
    return array("title" => $title, "content" => $content, "jquerycode" => $jquerycode);
}
Example #2
0
function oath_hook_admin_client_profile_tab_fields($vars)
{
    $secret = get_query_val('mod_oath_client', 'secret', "userid = '{$vars['userid']}'");
    if ($secret) {
        return array('OATH Addon' => '<label><input type="checkbox" name="disable_twofactor" value="1" /> Tick and save to disable two-factor authentication for this client</label>');
    } else {
        return array();
    }
}
Example #3
0
/**
 *
 * @ WHMCS FULL DECODED & NULLED
 *
 * @ Version  : 5.2.15
 * @ Author   : MTIMER
 * @ Release on : 2013-12-24
 * @ Website  : http://www.mtimer.cn
 *
 * */
function hook_licensing_addon_log_prune($vars)
{
    $logprune = get_query_val("tbladdonmodules", "value", array("module" => "licensing", "setting" => "logprune"));
    if (is_numeric($logprune)) {
        full_query("DELETE FROM mod_licensinglog WHERE datetime<='" . date("Y-m-d", mktime(0, 0, 0, date("m"), date("d") - $logprune, date("Y"))) . "'");
    }
    full_query("DELETE FROM mod_licensing WHERE serviceid NOT IN (SELECT id FROM tblhosting)");
    full_query("OPTIMIZE TABLE mod_licensinglog");
}
Example #4
0
function vultr_CreateAccount($params)
{
    $apikey = $params["serverpassword"];
    $ch = curl_init();
    $serviceid = $params["serviceid"];
    $DCID = $params['configoptions']['Datacenter'];
    $VPSPLANID = $params['configoptions']['Resource Plan'];
    $OS = $params['configoptions']['OS'];
    $SNAPSHOTID = $params['configoptions']['Snapshot'];
    curl_setopt($ch, CURLOPT_URL, "https://api.vultr.com/v1/server/create?api_key=" . $apikey);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "DCID={$DCID}&VPSPLANID={$VPSPLANID}&OSID={$OS}&SNAPSHOTID={$SNAPSHOTID}&label={$serviceid}&enable_ipv6=yes");
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $response = json_decode(curl_exec($ch), 1);
    $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($http_status == "200") {
        $successful = true;
        $server_id = $response[SUBID];
    } else {
        $errorinfo = "API error. " . $http_status;
    }
    curl_close($ch);
    if ($successful) {
        sleep(60);
        //wait 60 secondes let vultr to install and then get server details
        $var1 = (int) get_query_val("tblcustomfields", "id", array("fieldname" => 'server_id', "relid" => $params['packageid']));
        update_query("tblcustomfieldsvalues", array("value" => $server_id), array("fieldid" => $var1, "relid" => $params['serviceid']));
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "https://api.vultr.com/v1/server/list?api_key=" . $apikey);
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $response2 = json_decode(curl_exec($ch), 1);
        $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        if ($http_status == "200") {
            $server_ip = $response2[$server_id]['main_ip'];
            $server_passwd = $response2[$server_id]['default_password'];
            $command = "encryptpassword";
            $adminuser = $params["serverusername"];
            $values["password2"] = $server_passwd;
            $server_passwd_entd_arry = localAPI($command, $values, $adminuser);
            $server_passwd_entd = $server_passwd_entd_arry[password];
        }
        curl_close($ch);
        if (empty($server_ip)) {
            $result = "success";
            $server_ip = "See client area";
            $server_password = "******";
        } else {
            $result = "success";
        }
        update_query("tblhosting", array("dedicatedip" => $server_ip, "username" => "root/administrator", "password" => "{$server_passwd_entd}"), array("id" => $params['serviceid']));
    } else {
        $result = "Something has gone wrong. Please manually check and/or create the droplet. Info: " . $errorinfo;
    }
    return $result;
}
Example #5
0
function widget_network_status_gettable()
{
    global $_ADMINLANG;
    $content = '<div class="fixed-height-container">
<table class="table table-condensed">
<tr style="background-color:#efefef;font-weight:bold;text-align:center"><td>' . $_ADMINLANG['mergefields']['servername'] . '</td><td>HTTP</td><td>' . $_ADMINLANG['home']['load'] . '</td><td>' . $_ADMINLANG['home']['uptime'] . '</td><td>' . $_ADMINLANG['home']['percentuse'] . '</td></tr>
';
    $id = '';
    $result = select_query("tblservers", "", array("disabled" => "0"), "name", "ASC");
    while ($data = mysql_fetch_array($result)) {
        $id = $data["id"];
        $name = $data['name'];
        $ipaddress = $data['ipaddress'];
        $maxaccounts = $data['maxaccounts'];
        $statusaddress = $data['statusaddress'];
        $active = $data['active'];
        $active = $active ? '*' : '';
        $numaccounts = get_query_val("tblhosting", "COUNT(*)", "server='{$id}' AND (domainstatus='Active' OR domainstatus='Suspended')");
        $percentuse = @round($numaccounts / $maxaccounts * 100, 0);
        $http = $serverload = $uptime = "-";
        if (isset($_POST['checknetwork'])) {
            $http = @fsockopen($ipaddress, 80, $errno, $errstr, 5);
            $http = $http ? "Online" : "Offline";
            if ($statusaddress) {
                $q = $statusaddress . "index.php";
                $ch = curl_init();
                curl_setopt($ch, CURLOPT_URL, $q);
                curl_setopt($ch, CURLOPT_HEADER, 0);
                curl_setopt($ch, CURLOPT_TIMEOUT, 5);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
                $filecontents = curl_exec($ch);
                curl_close($ch);
                preg_match('/\\<load\\>(.*?)\\<\\/load\\>/', $filecontents, $serverload);
                preg_match('/\\<uptime\\>(.*?)\\<\\/uptime\\>/', $filecontents, $uptime);
                $serverload = $serverload[1];
                $uptime = $uptime[1];
                if (!$serverload) {
                    $serverload = "-";
                }
                if (!$uptime) {
                    $uptime = "-";
                }
            }
        }
        $content .= '<tr bgcolor="#ffffff"><td align="center">' . $name . '</td><td align="center">' . $http . '</td><td align="center">' . $serverload . '</td><td align="center">' . $uptime . '</td><td align="center">' . $percentuse . '%</td></tr>';
    }
    if (!$id) {
        $content .= '<tr bgcolor="#ffffff"><td colspan="5" align="center">' . $_ADMINLANG['global']['norecordsfound'] . '</td></tr>';
    }
    $content .= '</table>
</div>';
    return $content;
}
Example #6
0
function chartdata_orders()
{
    $chartdata = array();
    $chartdata['cols'][] = array('label' => 'Year', 'type' => 'string');
    $chartdata['cols'][] = array('label' => 'Completed Orders', 'type' => 'number');
    $chartdata['cols'][] = array('label' => 'Total Orders', 'type' => 'number');
    for ($i = 14; $i >= 0; $i--) {
        $date = mktime(0, 0, 0, date("m"), date("d") - $i, date("Y"));
        $number = get_query_val("tblorders", "COUNT(*)", "date LIKE '" . date("Y-m-d", $date) . "%' AND status='Active'");
        $number2 = get_query_val("tblorders", "COUNT(*)", "date LIKE '" . date("Y-m-d", $date) . "%'");
        $chartdata['rows'][] = array('c' => array(array('v' => date("dS", $date)), array('v' => (int) $number), array('v' => (int) $number2)));
    }
    return $chartdata;
}
Example #7
0
/**
 * Twilio Call-Redirect WHMCS module
 *
 * @author Frank Laszlo <*****@*****.**>
 * @version 1.0
 * @package twilio-whmcs
 */
function twilio_adminheader_hook($vars)
{
    // Get config values
    $config = array();
    $d = select_query('mod_twilio_config', '*', array());
    while ($res = mysql_fetch_assoc($d)) {
        $setting = $res['setting'];
        $value = $res['val'];
        $config[$setting] = $value;
    }
    // Get module access
    $access = get_query_val('tbladdonmodules', 'value', 'module="twilio" AND setting="access"');
    $access = explode(',', $access);
    // Get admin role
    $adminid = $_SESSION['adminid'];
    $adminrole = get_query_val('tbladmins', 'roleid', 'id=' . $adminid);
    if (in_array($adminrole, $access, true)) {
        // First we need to check if the port is even open, otherwise the admin page will take forever to load.
        $timeout = '5.00';
        if ($fp = fsockopen($_SERVER['HTTP_HOST'], $config['client_port'], $errno, $errstr, (double) $timeout)) {
            $socketio = $_SERVER['HTTP_HOST'] . ':' . $config['client_port'];
            $code = '
<script src="https://' . $socketio . '/socket.io/socket.io.js"></script>
<script>
	var socket = io.connect("' . $socketio . '", {secure: true});
	socket.on("data", function (data) {
		var d = JSON.parse(data);
		switch (d.type) {
			case "client":
				var ok = confirm("You have an incoming call for Client ID: "+d.clientid+". Would you like to navigate to this clients page?");
				var url = "clientssummary.php?userid="+d.clientid;
				break;
			case "ticket":
				var ok = confirm("You have an incoming call regarding Ticket ID: "+d.ticketid+". Would you like to navigate to this ticket?");
				var url = "supporttickets.php?action=viewticket&id="+d.ticketid;
				break;
		}
		if (ok) {
			document.location = url;
		}
	});
</script>';
            return $code;
        } else {
            return '<!-- Cannot connect to node.js server -->';
        }
    } else {
        return '<!-- No access to twilio call-redirect -->';
    }
}
Example #8
0
function paywall_api_key($vars)
{
    if ($vars["clientareaaction"] == "creditcard" || $vars["filename"] == "creditcard") {
        $error_message = $_SESSION['paymentwall_errors'];
        $pending_review = $_SESSION['paywall_pending_review'];
        unset($_SESSION['paymentwall_errors']);
        unset($_SESSION['paywall_pending_review']);
        if (get_query_val("tblpaymentgateways", "value", array("gateway" => "paymentwallbrick", "setting" => "test_mode")) == "on") {
            return array("paymentwall_pendingreview" => $pending_review, "paymentwall_errors" => $error_message, "brick_public_key" => get_query_val("tblpaymentgateways", "value", array("gateway" => "paymentwallbrick", "setting" => "test_public_key")));
        } else {
            return array("paymentwall_pendingreview" => $pending_review, "paymentwall_errors" => $error_message, "brick_public_key" => get_query_val("tblpaymentgateways", "value", array("gateway" => "paymentwallbrick", "setting" => "public_key")));
        }
    }
}
Example #9
0
function hook_project_management_adminticketinfo($vars)
{
    global $aInt;
    global $jscode;
    global $jquerycode;
    $ticketid = $vars['ticketid'];
    $ticketdata = get_query_vals("tbltickets", "userid,title,tid", array("id" => $ticketid));
    $tid = $ticketdata['tid'];
    require ROOTDIR . "/modules/addons/project_management/project_management.php";
    $projectrows = "";
    $result = select_query("mod_project", "mod_project.*,(SELECT CONCAT(firstname,' ',lastname) FROM tbladmins WHERE id=mod_project.adminid) AS adminname", "ticketids LIKE '%" . mysql_real_escape_string($tid) . "%'");
    while ($data = mysql_fetch_array($result)) {
        $timerid = get_query_val("mod_projecttimes", "id", array("projectid" => $data['id'], "end" => "", "adminid" => $_SESSION['adminid']), "start", "DESC");
        $timetrackinglink = $timerid ? "<a href=\"#\" onclick=\"projectendtimer('" . $data['id'] . "');return false\"><img src=\"../modules/addons/project_management/images/notimes.png\" align=\"absmiddle\" border=\"0\" /> Stop Tracking Time</a>" : "<a href=\"#\" onclick=\"projectstarttimer('" . $data['id'] . "');return false\"><img src=\"../modules/addons/project_management/images/starttimer.png\" align=\"absmiddle\" border=\"0\" /> Start Tracking Time</a>";
        $projectrows .= "<tr><td><a href=\"addonmodules.php?module=project_management&m=view&projectid=" . $data['id'] . "\">" . $data['id'] . "</a></td><td><a href=\"addonmodules.php?module=project_management&m=view&projectid=" . $data['id'] . "\">" . $data['title'] . "</a> <span id=\"projecttimercontrol" . $data['id'] . "\" class=\"tickettimer\">" . $timetrackinglink . "</span></td><td>" . $data['adminname'] . "</td><td>" . fromMySQLDate($data['created']) . "</td><td>" . fromMySQLDate($data['duedate']) . "</td><td>" . fromMySQLDate($data['lastmodified']) . "</td><td>" . $data['status'] . "</td></tr>";
    }
    $code = "<link href=\"../modules/addons/project_management/css/style.css\" rel=\"stylesheet\" type=\"text/css\" />\n\n<div id=\"projectscont\" style=\"margin:0 0 10px 0;padding:5px;border:2px dashed #e0e0e0;background-color:#fff;-moz-border-radius: 6px;-webkit-border-radius: 6px;-o-border-radius: 6px;border-radius: 6px;" . ($projectrows ? "" : "display:none;") . "\">\n\n<h2 style=\"margin:0 0 5px 0;text-align:center;background-color:#f2f2f2;-moz-border-radius: 6px;-webkit-border-radius: 6px;-o-border-radius: 6px;border-radius: 6px;\">Projects</h2>\n\n<div class=\"tablebg\" style=\"padding:0 20px;\">\n<table class=\"datatable\" width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"3\" id=\"ticketprojectstbl\">\n<tr><th>Project ID</th><th>Title</th><th>Assigned To</th><th>Created</th><th>Due Date</th><th>Last Updated</th><th>Status</th></tr>\n" . $projectrows . "\n</table>\n</div>\n\n</div>\n\n";
    if (project_management_checkperm("Create New Projects")) {
        $code .= "<span style=\"float:right;padding:0 50px 15px 0;\"><a href=\"#\" onclick=\"createnewproject();return false\" class=\"create\"><img src=\"images/icons/add.png\" align=\"top\" border=\"0\" /> <b>Create New Project</b></a></span>";
    }
    $code .= "\n<script>\n\$(document).on(\"keyup\",\"#cpclientname\",function () {\n\tvar ticketuseridsearchlength = \$(\"#cpclientname\").val().length;\n\tif (ticketuseridsearchlength>2) {\n\t\$.post(\"search.php\", { ticketclientsearch: 1, value: \$(\"#cpclientname\").val() },\n\t    function(data){\n            if (data) {\n                \$(\"#cpticketclientsearchresults\").html(data.replace(\"searchselectclient(\",\"projectsearchselectclient(\"));\n                \$(\"#cpticketclientsearchresults\").slideDown(\"slow\");\n                \$(\"#cpclientsearchcancel\").fadeIn();\n            }\n        });\n\t}\n});\nfunction projectsearchselectclient(userid,name,email) {\n    \$(\"#cpclientname\").val(name);\n    \$(\"#cpuserid\").val(userid);\n    \$(\"#cpclientsearchcancel\").fadeOut();\n\t\$(\"#cpticketclientsearchresults\").slideUp(\"slow\");\n}\n\nfunction createnewproject() {\n\t\$(\"#popupcreatenew\").show();\n\t\$(\"#popupstarttimer\").hide();\n\t\$(\"#popupendtimer\").hide();\n\t\$(\"#createnewcont\").slideDown();\n}\nfunction createproject() {\n\tinputs = \$(\"#ajaxcreateprojectform\").serializeArray();\n\t\$.post(\"addonmodules.php?module=project_management&createproj=1&ajax=1\", { input : inputs },\n\t\tfunction (data) {\n\t\t\tif(data == \"0\"){\n\t\t\t\talert(\"You do not have permission to create project\");\n\t\t\t} else {\n\t\t\t\t\$(\"#createnewcont\").slideUp();\n                \$(\"#ticketprojectstbl\").append(data);\n\t\t\t\t\$(\"#projectscont\").slideDown();\n\t\t\t}\n\t\t});\n}\n\nfunction projectstarttimer(projectid) {\n    \$(\"#ajaxstarttimerformprojectid\").val(projectid);\n\t\$(\"#popupcreatenew\").hide();\n\t\$(\"#popupstarttimer\").show();\n\t\$(\"#popupendtimer\").hide();\n\t\$(\"#createnewcont\").slideDown();\n}\n\nfunction projectendtimer(projectid) {\n\t\$(\"#popupcreatenew\").hide();\n\t\$(\"#popupstarttimer\").hide();\n\t\$(\"#popupendtimer\").show();\n\t\$(\"#createnewcont\").slideDown();\n}\n\nfunction projectstarttimersubmit() {\n\t\$.post(\"addonmodules.php?module=project_management&m=view\", \"a=hookstarttimer&\"+\$(\"#ajaxstarttimerform\").serialize(),\n\t\tfunction (data) {\n\t\t\tif(data == \"0\"){\n\t\t\t\talert(\"Could not start timer.\");\n\t\t\t} else {\n\t\t\t\t\$(\"#createnewcont\").slideUp();\n                var projid = \$(\"#ajaxstarttimerformprojectid\").val();\n\t\t\t\t\$(\"#projecttimercontrol\"+projid).html(\"<a href=\"//\" onclick=\"projectendtimer('\"+projid+\"');return false\"><img src=\"../modules/addons/project_management/images/notimes.png\" align=\"absmiddle\" border=\"0\" /> Stop Tracking Time</a>\");\n\t\$(\"#activetimers\").html(data);\n\t\t\t}\n\t\t});\n}\nfunction projectendtimersubmit(projectid,timerid) {\n\t\$.post(\"addonmodules.php?module=project_management&m=view\", \"a=hookendtimer&timerid=\"+timerid+\"&ticketnum=" . $tid . "\",\n\t\tfunction (data) {\n\t\t\tif (data == \"0\") {\n\t\t\t\talert(\"Could not stop timer.\");\n\t\t\t} else {\n\t\t\t\t\$(\"#createnewcont\").slideUp();\n\t\t\t\t\$(\"#projecttimercontrol\"+projectid).html(\"<a href=\"//\" onclick=\"projectstarttimer('\"+projectid+\"');return false\"><img src=\"../modules/addons/project_management/images/starttimer.png\" align=\"absmiddle\" border=\"0\" /> Start Tracking Time</a>\");\n\t\t\$(\"#activetimers\").html(data);\n\t\t\t}\n\t\t});\n}\n\nfunction projectpopupcancel() {\n\t\$(\"#createnewcont\").slideUp();\n}\n\n</script>\n\n<div class=\"projectmanagement\">\n\n<div id=\"createnewcont\" style=\"display:none;\">\n\n<div class=\"createnewcont2\">\n\n<div class=\"createnewproject\" id=\"popupcreatenew\" style=\"display:none\">\n<div class=\"title\">Create New Project</div>\n<form id=\"ajaxcreateprojectform\">\n<div class=\"label\">Title</div>\n<input type=\"text\" name=\"title\" class=\"title\" />\n<div class=\"float\">\n<div class=\"label\">Created</div>\n<input type=\"text\" name=\"created\" class=\"datepick\" value=\"" . getTodaysDate() . "\" />\n</div>\n<div class=\"float\">\n<div class=\"label\">Due Date</div>\n<input type=\"text\" name=\"duedate\" class=\"datepick\" value=\"" . getTodaysDate() . "\" />\n</div>\n<div class=\"float\">\n<div class=\"label\">Assigned To</div>\n<select class=\"title\" name=\"adminid\">";
    $code .= "<option value=\"0\">None</option>";
    $result = select_query("tbladmins", "id,firstname,lastname", "", "firstname` ASC,`lastname", "ASC");
    while ($data = mysql_fetch_array($result)) {
        $aid = $data['id'];
        $adminfirstname = $data['firstname'];
        $adminlastname = $data['lastname'];
        $code .= "<option value=\"" . $aid . "\"";
        if ($aid == $adminid) {
            $code .= " selected";
        }
        $code .= ">" . $adminfirstname . " " . $adminlastname . "</option>";
    }
    $code .= "</select>\n</div>\n<div class=\"float\">\n<div class=\"label\">Ticket #</div>\n<input type=\"text\" name=\"ticketnum\" class=\"ticketnum\" value=\"" . $tid . "\" />\n</div>\n<div class=\"clear\"></div>\n<div class=\"float\">\n<div class=\"label\">Associated Client</div>\n<input type=\"hidden\" name=\"userid\" id=\"cpuserid\" /><input type=\"text\" id=\"cpclientname\" value=\"" . $clientname . "\" class=\"title\" onfocus=\"if(this.value=='" . addslashes($clientname) . "')this.value=''\" /> <img src=\"images/icons/delete.png\" alt=\"" . $vars['_lang']['cancel'] . "\" align=\"right\" id=\"clientsearchcancel\" height=\"16\" width=\"16\"><div id=\"cpticketclientsearchresults\" style=\"z-index:2000;\"></div>\n</div>\n<br /><br />\n<div align=\"center\"><input type=\"button\" value=\"Create\" onclick=\"createproject()\" class=\"create\" /> <input type=\"button\" value=\"Cancel\" class=\"create\" onclick=\"projectpopupcancel();return false\" /></div>\n</form>\n</div>\n\n<div class=\"createnewproject\" id=\"popupstarttimer\" style=\"display:none\">\n<div class=\"title\">Start Time Tracking</div>\n<form id=\"ajaxstarttimerform\">\n<input type=\"hidden\" id=\"ajaxstarttimerformprojectid\" name=\"projectid\">\n<input type=\"hidden\" name=\"ticketnum\" value=\"" . $tid . "\" />\n<div class=\"label\">Select Existing Task</div>\n<select class=\"title\" style=\"min-width:450px\" name=\"taskid\">";
    $code .= "<option value=\"\">Choose one...</option>";
    $result = select_query("mod_projecttasks", "mod_project.title, mod_projecttasks.id, mod_projecttasks.projectid, mod_projecttasks.task", array("mod_project.ticketids" => array("sqltype" => "LIKE", "value" => (int) $tid)), "", "", "", "mod_project ON mod_projecttasks.projectid=mod_project.id", "", "", "", "mod_project ON mod_projecttasks.projectid=mod_project.id");
    while ($data = mysql_fetch_array($result)) {
        $code .= "<option value=\"" . $data['id'] . "\"";
        $code .= ">" . $data['projectid'] . " - " . $data['title'] . " - " . $data['task'] . "</option>";
    }
    $code .= "</select><br />\n<div class=\"label\">Or Create New Task</div>\n<input type=\"text\" name=\"title\" class=\"title\" />\n<br />\n<div align=\"center\"><input type=\"button\" value=\"Start\" onclick=\"projectstarttimersubmit();return false\" class=\"create\" /> <input type=\"button\" value=\"Cancel\" class=\"create\" onclick=\"projectpopupcancel();return false\" /></div>\n</form>\n</div>\n</div>\n\n<div class=\"createnewproject\" id=\"popupendtimer\" style=\"display:none\">\n<div class=\"title\">Stop Time Tracking</div>\n<form id=\"ajaxendtimerform\">\n<input type=\"hidden\" id=\"ajaxendtimerformprojectid\" name=\"projectid\">\n<br />\n<b>Active Timers</b>:<br /><br />\n<div id=\"activetimers\">\n";
    $result = select_query("mod_projecttimes", "mod_projecttimes.id, mod_projecttimes.projectid, mod_project.title, mod_projecttimes.taskid, mod_projecttasks.task, mod_projecttimes.start", array("mod_projecttimes.adminid" => $_SESSION['adminid'], "mod_projecttimes.end" => "", "mod_project.ticketids" => array("sqltype" => "LIKE", "value" => (int) $tid)), "", "", "", "mod_projecttasks ON mod_projecttimes.taskid=mod_projecttasks.id INNER JOIN mod_project ON mod_projecttimes.projectid=mod_project.id");
    while ($data = mysql_fetch_array($result)) {
        $code .= "<div class=\"stoptimer" . $data['id'] . "\" style=\"padding-bottom:10px;\"><em>" . $data['title'] . " - Project ID " . $data['projectid'] . "</em><br />&nbsp;&raquo; " . $data['task'] . "<br />Started at " . fromMySQLDate(date("Y-m-d H:i:s", $data['start']), 1) . ":" . date("s", $data['start']) . " - <a href=\"#\" onclick=\"projectendtimersubmit('" . $data['projectid'] . "','" . $data['id'] . "');return false\"><strong>Stop Timer</strong></a></div>";
    }
    $code .= "\n</div>\n<br />\n<div align=\"center\"><input type=\"button\" value=\"Cancel\" class=\"create\" onclick=\"projectpopupcancel();return false\" /></div>\n</form>\n</div>\n\n</div>\n\n</div>\n\n";
    return $code;
}
Example #10
0
function widget_my_notes($vars)
{
    $title = "My Notes";
    $mynotes = get_query_val("tbladmins", "notes", array("id" => $vars['adminid']));
    $content = '
<script>
function widgetnotessave() {
    $.post("index.php", { action: "savenotes", notes: $("#widgetnotesbox").val(), token: "' . generate_token('plain') . '" });
    $("#widgetnotesconfirm").slideDown().delay(2000).slideUp();
}
</script>
<div align="center">
<div id="widgetnotesconfirm" style="display:none;margin:0 0 5px 0;padding:5px 20px;background-color:#DBF3BA;font-weight:bold;color:#6A942C;">Notes Saved Successfully!</div>
<textarea id="widgetnotesbox" style="width:95%;height:100px;">' . $mynotes . '</textarea>
<input type="button" value="Save Notes" onclick="widgetnotessave()" />
</div>
    ';
    return array('title' => $title, 'content' => $content);
}
Example #11
0
/**
 *
 * @ WHMCS FULL DECODED & NULLED
 *
 * @ Version  : 5.2.15
 * @ Author   : MTIMER
 * @ Release on : 2013-12-24
 * @ Website  : http://www.mtimer.cn
 *
 * */
function widget_paypal_addon($vars)
{
    $title = "PayPal Overview";
    $params = array();
    $result = select_query("tbladdonmodules", "setting,value", array("module" => "paypal_addon"));
    while ($data = mysql_fetch_array($result)) {
        $params[$data[0]] = $data[1];
    }
    $content = "";
    $adminroleid = get_query_val("tbladmins", "roleid", array("id" => $_SESSION['adminid']));
    if ($params["showbalance" . $adminroleid]) {
        $url = "https://api-3t.paypal.com/nvp";
        $postfields = $resultsarray = array();
        $postfields['USER'] = $params['username'];
        $postfields['PWD'] = $params['password'];
        $postfields['SIGNATURE'] = $params['signature'];
        $postfields['METHOD'] = "GetBalance";
        $postfields['RETURNALLCURRENCIES'] = "1";
        $postfields['VERSION'] = "56.0";
        $result = curlCall($url, $postfields);
        $resultsarray2 = explode("&", $result);
        foreach ($resultsarray2 as $line) {
            $line = explode("=", $line);
            $resultsarray[$line[0]] = urldecode($line[1]);
        }
        $paypalbal = array();
        if (strtolower($resultsarray['ACK']) != "success") {
            $paypalbal[] = "Error: " . $resultsarray['L_LONGMESSAGE0'];
        } else {
            $i = 0;
            while ($i <= 20) {
                if (isset($resultsarray["L_AMT" . $i])) {
                    $paypalbal[] = number_format($resultsarray["L_AMT" . $i], 2, ".", ",") . " " . $resultsarray["L_CURRENCYCODE" . $i];
                }
                ++$i;
            }
        }
        $content .= "<div style=\"margin:10px;padding:10px;background-color:#EFFAE4;text-align:center;font-size:16px;color:#000;\">PayPal Balance: <b>" . implode(" ~ ", $paypalbal) . "</b></div>";
    }
    $content .= "<form method=\"post\" action=\"addonmodules.php?module=paypal_addon\">\n<div align=\"center\" style=\"margin:10px;font-size:16px;\">Lookup PayPal Transaction ID: <input type=\"text\" name=\"transid\" size=\"30\" value=\"" . $_POST['transid'] . "\" style=\"font-size:16px;\" /> <input type=\"submit\" name=\"search\" value=\"Go\" /></div>\n<div align=\"right\"><a href=\"addonmodules.php?module=paypal_addon\">Advanced Search &raquo;</a></div>\n</form>";
    return array("title" => $title, "content" => $content);
}
Example #12
0
function widget_my_notes($vars)
{
    global $_ADMINLANG;
    $title = "My Notes";
    $mynotes = get_query_val("tbladmins", "notes", array("id" => $vars['adminid']));
    $content = '
<script>
function widgetnotessave() {
    $.post("index.php", { action: "savenotes", notes: $("#widgetnotesbox").val(), token: "' . generate_token('plain') . '" });
    $("#widgetnotesconfirm").slideDown().delay(2000).slideUp();
}
</script>
<div id="widgetnotesconfirm" style="display:none;margin:0 0 5px 0;padding:5px 20px;background-color:#DBF3BA;font-weight:bold;color:#6A942C;">Notes Saved Successfully!</div>
<form>
    <textarea id="widgetnotesbox" style="height:100px;" class="form-control">' . $mynotes . '</textarea>
    <div class="widget-footer">
        <input type="reset" value="' . $_ADMINLANG['global']['cancel'] . '" class="btn btn-default btn-sm" /> <input type="button" value="Save Notes" onclick="widgetnotessave()" class="btn btn-info btn-sm" />
    </div>
</form>
    ';
    return array('title' => $title, 'content' => $content);
}
Example #13
0
function paypalexpress_orderformcheckout($params)
{
    $orderid = get_query_val("tblorders", "id", array("invoiceid" => $params['invoiceid']));
    update_query("tblhosting", array("paymentmethod" => "paypal"), array("orderid" => $orderid, "paymentmethod" => "paypalexpress"));
    update_query("tblhostingaddons", array("paymentmethod" => "paypal"), array("orderid" => $orderid, "paymentmethod" => "paypalexpress"));
    update_query("tbldomains", array("paymentmethod" => "paypal"), array("orderid" => $orderid, "paymentmethod" => "paypalexpress"));
    $finalPaymentAmount = $_SESSION['Payment_Amount'];
    $postfields = array();
    $postfields['TOKEN'] = $_SESSION['paypalexpress']['token'];
    $postfields['PAYERID'] = $_SESSION['paypalexpress']['payerid'];
    $postfields['PAYMENTREQUEST_0_PAYMENTACTION'] = "SALE";
    $postfields['PAYMENTREQUEST_0_AMT'] = $params['amount'];
    $postfields['PAYMENTREQUEST_0_CURRENCYCODE'] = $params['currency'];
    $postfields['IPADDRESS'] = $_SERVER['SERVER_NAME'];
    $results = paypalexpress_api_call($params, "DoExpressCheckoutPayment", $postfields);
    $ack = strtoupper($results['ACK']);
    if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
        $transactionId = $results['PAYMENTINFO_0_TRANSACTIONID'];
        $transactionType = $results['PAYMENTINFO_0_TRANSACTIONTYPE'];
        $paymentType = $results['PAYMENTINFO_0_PAYMENTTYPE'];
        $orderTime = $results['PAYMENTINFO_0_ORDERTIME'];
        $amt = $results['PAYMENTINFO_0_AMT'];
        $currencyCode = $results['PAYMENTINFO_0_CURRENCYCODE'];
        $feeAmt = $results['PAYMENTINFO_0_FEEAMT'];
        $settleAmt = $results['PAYMENTINFO_0_SETTLEAMT'];
        $taxAmt = $results['PAYMENTINFO_0_TAXAMT'];
        $exchangeRate = $results['PAYMENTINFO_0_EXCHANGERATE'];
        $paymentStatus = $results['PAYMENTINFO_0_PAYMENTSTATUS'];
        if ($paymentStatus == "Completed") {
            return array("status" => "success", "transid" => $transactionId, "fee" => $feeAmt, "rawdata" => $results);
        }
        if ($paymentStatus == "Pending") {
            return array("status" => "payment pending", "rawdata" => $results);
        }
        return array("status" => "invalid status", "rawdata" => $results);
    }
    return array("status" => "error", "rawdata" => $results);
}
Example #14
0
     $userid = $data['userid'];
     $description = $data['description'];
     $hours = $data['hours'];
     $amount = $data['amount'];
     if ($hours != 0) {
         $amount = format_as_currency($amount / $hours);
     }
     $recur = $data['recur'];
     $recurcycle = $data['recurcycle'];
     $recurfor = $data['recurfor'];
     $invoiceaction = $data['invoiceaction'];
     $invoicecount = $data['invoicecount'];
     $duedate = fromMySQLDate($data['duedate']);
 } else {
     $pagetitle = $aInt->lang("billableitems", "additem");
     $clientcheck = get_query_val("tblclients", "id", "");
     if (!$clientcheck) {
         $aInt->gracefulExit($aInt->lang("billableitems", "noclientsmsg"));
     }
     $invoiceaction = 0;
     $recur = 0;
     $duedate = getTodaysDate();
     $hours = "0.0";
     $amount = "0.00";
     $invoicecount = 0;
     $options = "";
     $result = select_query("tblproducts", "tblproducts.id,tblproducts.gid,tblproducts.name,tblproductgroups.name AS groupname", "", "tblproductgroups`.`order` ASC,`tblproducts`.`order` ASC,`name", "ASC", "", "tblproductgroups ON tblproducts.gid=tblproductgroups.id");
     while ($data = mysql_fetch_array($result)) {
         $pid = $data['id'];
         $pname = $data['name'];
         $ptype = $data['groupname'];
Example #15
0
}
$amount = $_REQUEST['amt'];
$callbackvars2 = explode("&amp;", $callbackvars);
foreach ($callbackvars2 as $value) {
    $values[] = explode("=", $value);
}
if ($code == "5") {
    logTransaction("Pay Offline", $orgipn, "Pending");
    exit;
}
if ($transid) {
    checkCbTransID($transid);
}
if ($code == "0") {
    $invoiceid = $values[0][1];
    if ($invoiceid) {
        checkCbInvoiceID($invoiceid, "PayOffline");
        addInvoicePayment($invoiceid, $transid, $amount, "", "payoffline");
        logTransaction("Pay Offline", $_REQUEST, "Successful");
        return 1;
    }
    $userid = $values[2][1];
    $userid = get_query_val("tblclients", "id", array("id" => $userid));
    if (!$userid) {
        logTransaction("Pay Offline", $_REQUEST, "Invoice Not Found");
        return 1;
    }
    insert_query("tblcredit", array("clientid" => $userid, "date" => "now()", "description" => "Pay Offline Transaction ID " . $transid, "amount" => $amount));
    update_query("tblclients", array("credit" => "+=" . $amount), array("id" => $userid));
    logTransaction("Pay Offline", $_REQUEST, "Credit Added");
}
Example #16
0
function twilio_output($vars)
{
    $modulelink = $vars['modulelink'];
    global $attachments_dir;
    if (isset($_POST)) {
        switch ($_POST['_a']) {
            case "modconfig":
                $POST = $_POST;
                unset($POST['token']);
                unset($POST['_a']);
                foreach ($POST as $keyname => $value) {
                    $currentval = get_query_val('mod_twilio_config', 'val', 'setting="' . $keyname . '"');
                    if ($currentval != $value) {
                        update_query('mod_twilio_config', array('val' => $value), array('setting' => $keyname));
                    }
                }
                $msg = 'The configuration settings have been successfully saved.';
                break;
            case "modnumbers":
                foreach ($_POST['numberid'] as $nid) {
                    $number = $_POST['number'][$nid];
                    $order = $_POST['order'][$nid];
                    $timeout = $_POST['timeout'][$nid];
                    $delete = $_POST['delete'][$nid];
                    if ($nid != 'NEW') {
                        if ($delete == '1') {
                            delete_query('mod_twilio_numbers', array('id' => $nid));
                        } else {
                            update_query('mod_twilio_numbers', array('number' => $number, 'timeout' => $timeout, 'order' => $order), array('id' => $nid));
                        }
                    } else {
                        if ($number != '') {
                            insert_query('mod_twilio_numbers', array('number' => $number, 'timeout' => $timeout, 'order' => $order));
                        }
                    }
                }
                $msg = 'Your numbers have been successfully modified.';
                break;
            case "uploadaudio":
                if (isset($_FILES)) {
                    $destdir = $attachments_dir . '/twilio';
                    if (!file_exists($destdir)) {
                        mkdir($destdir);
                    }
                    foreach ($_FILES as $keyname => $val) {
                        if ($val['name'] != '') {
                            $curerr = 0;
                            // Check file size
                            if ((int) $val['size'] > 2048000) {
                                $error .= '<br />' . $val['name'] . ' is too large.';
                                $curerr = 1;
                                // Check file type
                            } elseif ($val['type'] != 'audio/mp3' && $val['type'] != 'audio/mpeg') {
                                $error .= '<br />' . $val['name'] . ' is not a valid MP3 file.';
                                $curerr = 1;
                            } else {
                                // File is good
                                $file = $destdir . '/' . $keyname . '.mp3';
                                if (file_exists($file)) {
                                    unlink($file);
                                }
                                if (move_uploaded_file($val['tmp_name'], $file)) {
                                    update_query('mod_twilio_config', array('val' => $file), array('setting' => $keyname));
                                } else {
                                    $error .= '<br />There was an error uploading ' . $val['name'] . '. Please check your error logs.';
                                    $curerr = 1;
                                }
                            }
                            if (!$curerr) {
                                $msg .= '<br />' . $val['name'] . ' has been successfully uploaded.';
                            }
                        }
                    }
                }
                break;
        }
    }
    // Get configured numbers
    $numbers = array();
    $d = select_query('mod_twilio_numbers', '*', array(), 'order', 'ASC');
    while ($res = mysql_fetch_assoc($d)) {
        $numbers[] = array('id' => $res['id'], 'number' => $res['number'], 'timeout' => $res['timeout'], 'order' => $res['order']);
    }
    // Get config values
    $config = array();
    $d = select_query('mod_twilio_config', '*', array());
    while ($res = mysql_fetch_assoc($d)) {
        $setting = $res['setting'];
        $value = $res['val'];
        $config[$setting] = $value;
    }
    // Return to last page
    if (isset($_REQUEST['last'])) {
        $last = $_REQUEST['last'];
    } else {
        $last = '0';
    }
    // Get server.js daemon status
    $timeout = '5.00';
    if ($fp = fsockopen($_SERVER['HTTP_HOST'], $config['client_port'], $errno, $errstr, (double) $timeout)) {
        $client_status = '<em>Current Status:</em> <span style="color: green; font-weight: bold;">Online</span>';
    } else {
        $client_status = '<em>Current Status:</em> <span style="color: red; font-weight: bold;">Unreachable</span>';
    }
    if ($fp = fsockopen('localhost', $config['server_port'], $errno, $errstr, (double) $timeout)) {
        $server_status = '<em>Current Status:</em> <span style="color: green; font-weight: bold;">Online</span>';
    } else {
        $server_status = '<em>Current Status:</em> <span style="color: red; font-weight: bold;">Online</span>';
    }
    print '<script>
			$(document).ready(function(){
				$(".tabbox").css("display","none");
				var selectedTab;
				$(".tab").click(function(){
					var elid = $(this).attr("id");
					$(".tab").removeClass("tabselected");
					$("#"+elid).addClass("tabselected");
					if (elid != selectedTab) {
						$(".tabbox").slideUp();
						$("#"+elid+"box").slideDown();
						selectedTab = elid;
					}
					$("#tab").val(elid.substr(3));
				});

				selectedTab = "tab' . $last . '";
				$("#tab' . $last . '").addClass("tabselected");
				$("#tab' . $last . 'box").css("display", "");
			});
			</script>
			<div id="content_padded">';
    if ($msg) {
        print '<div class="infobox">' . $msg . '</div>';
    }
    if ($error) {
        print '<div class="errorbox">' . $error . '</div>';
    }
    print '<div id="tabs">
				<ul>
					<li id="tab0" class="tab"><a href="javascript:;">Configurations</a></li>
					<li id="tab1" class="tab"><a href="javascript:;">Phone Numbers</a></li>
					<li id="tab2" class="tab"><a href="javascript:;">Upload Audio Files</a></li>
				</ul>
			</div>
			
			<div id="tab0box" class="tabbox">
				<div id="tab_content">
					<h3>Module Configurations</h3>
					<p align="left">
						<strong>Instructions:</strong> Please configure ALL of the options below. Leaving options unset will likely cause unexpected errors to occur.<br /><br />
						<strong>Audio Mode:</strong> This option chooses whether or not you\'d like to use the built in text to speech engine, or record your own message. If you select Audio File, please ensure you have uploaded the coresponding audio file in the "Upload Audio Files" tab.<br />
						<strong>Text:</strong> If you selected Text to Speech in the previous option, this will be what is read to your callers.<br />
						<strong>Invalid Input Audio Mode:</strong> Much like the Audio Mode above, this option lets you select how you wish to let the caller know their input was not recognized.<br />
						<strong>Invalid Input Text:</strong> This will be what is read to the caller if you selected the Text to Speech option above.
					</p>
					<br />
					<br />
					<form method="POST" action="' . $modulelink . '&last=0">
						<input type="hidden" name="_a" value="modconfig" />
						<table class="form" border="0" cellpadding="3" cellspacing="1" width="75%" align="center">
						<!-- " -->
							<tr>
								<td colspan="2" align="center">
									<h4>Global Configurations</h4>
									These are the global configurations for the module.
								</td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Client Port</strong></td>
								<td class="fieldarea">
									<input type="text" size="10" name="client_port" value="' . $config['client_port'] . '" /> Client Port configured in server.js
									<div style="float: right; padding-right: 10px;">' . $client_status . '</div>
								</td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Server Port</strong></td>
								<td class="fieldarea">
									<input type="text" size="10" name="server_port" value="' . $config['server_port'] . '" /> Server Port configured in server.js
									<div style="float: right; padding-right: 10px;">' . $server_status . '</div>
								</td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Gather Timeout</strong></td>
								<td class="fieldarea"><input type="text" size="10" name="gather_timeout" value="' . $config['gather_timeout'] . '" /> Amount of time to wait for caller input</td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Voicemail Email Address</strong></td>
								<td class="fieldarea"><input type="text" size="30" name="voicemail_email" value="' . $config['voicemail_email'] . '" /> Email Address to send voicemails to</td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Voicemail Audio Mode</strong></td>
								<td class="fieldarea">';
    echo twilio_modeselect('voicemail_mode', $config);
    print '						</td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Voicemail Text</strong></td>
								<td class="fieldarea"><textarea name="voicemail_text" rows="10" cols="80">' . $config['voicemail_text'] . '</textarea></td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Invalid Input Audio Mode</strong></td>
								<td class="fieldarea">';
    echo twilio_modeselect('invalid_request_mode', $config);
    print '						</td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Invalid Input Text</strong></td>
								<td class="fieldarea"><textarea name="invalid_request_text" rows="10" cols="80">' . $config['invalid_request_text'] . '</textarea></td>
							</tr>
						</table>
						<table class="form" border="0" cellpadding="3" cellspacing="1" width="75%" align="center">
						<!-- " -->
							<tr>
								<td colspan="2" align="center">
									<h4>Introduction</h4>
									These settings are relevent to when the caller first calls into the phone system. It should say something along the lines of: <br /><em>"Thank you for calling Widgets Incorporated. Please press 1 if this call is regarding an existing support ticket, please press 2 for all other inqueries."</em>
								</td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Audio Mode</strong></td>
								<td class="fieldarea">';
    echo twilio_modeselect('intro_mode', $config);
    print '						</td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Text</strong></td>
								<td class="fieldarea"><textarea name="intro_text" rows="10" cols="80">' . $config['intro_text'] . '</textarea></td>
							</tr>
						</table>
						<table class="form" border="0" cellpadding="3" cellspacing="1" width="75%" align="center">
						<!-- " -->
							<tr>
								<td colspan="2" align="center">
									<h4>Step 1 (Ticket)</h4>
									These settings are relevent to when the caller selects option 1 from the introduction. It should say something along the lines of: <br /><em>"Please enter your ticket ID number, followed by the pound sign."</em>
								</td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Audio Mode</strong></td>
								<td class="fieldarea">';
    echo twilio_modeselect('step1_ticket_mode', $config);
    print '						</td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Text</strong></td>
								<td class="fieldarea"><textarea name="step1_ticket_text" rows="10" cols="80">' . $config['step1_ticket_text'] . '</textarea></td>
							</tr>
						</table>
						<table class="form" border="0" cellpadding="3" cellspacing="1" width="75%" align="center">
						<!-- " -->
							<tr>
								<td colspan="2" align="center">
									<h4>Step 1 (Client)</h4>
									These settings are relevent to when the caller selects option 2 from the introduction. It should say something along the lines of: <br /><em>"Please enter your client ID number, followed by the pound sign."</em>
								</td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Audio Mode</strong></td>
								<td class="fieldarea">';
    echo twilio_modeselect('step1_client_mode', $config);
    print '						</td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Text</strong></td>
								<td class="fieldarea"><textarea name="step1_client_text" rows="10" cols="80">' . $config['step1_client_text'] . '</textarea></td>
							</tr>
						</table>
						<table class="form" border="0" cellpadding="3" cellspacing="1" width="75%" align="center">
						<!-- " -->
							<tr>
								<td colspan="2" align="center">
									<h4>Step 2 (Ticket)</h4>
									These settings are relevent to when the caller enters his or her ticket ID number.<br />You can use custom variables here to insert client details into your message. Please see the <a href="#variables">table</a> at the bottom of this page.
								</td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Audio Mode</strong></td>
								<td class="fieldarea">';
    echo twilio_modeselect('step2_ticket_mode', $config);
    print '						</td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Text</strong></td>
								<td class="fieldarea"><textarea name="step2_ticket_text" rows="10" cols="80">' . $config['step2_ticket_text'] . '</textarea></td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Invalid Input Audio Mode</strong></td>
								<td class="fieldarea">';
    echo twilio_modeselect('step2_ticket_sorry_mode', $config);
    print '					</tr>
							<tr>
								<td class="fieldlabel"><strong>Invalid Input Text</strong></td>
								<td class="fieldarea"><textarea name="step2_ticket_sorry_text" rows="10" cols="80">' . $config['step2_ticket_sorry_text'] . '</textarea></td>
							</tr>
						</table>
						<table class="form" border="0" cellpadding="3" cellspacing="1" width="75%" align="center">
						<!-- " -->
							<tr>
								<td colspan="2" align="center">
									<h4>Step 2 (Client)</h4>
									These settings are relevent to when the caller enters his or her client ID number.<br />You can use custom variables here to insert client details into your message. Please see the <a href="#variables">table</a> at the bottom of this page.
								</td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Audio Mode</strong></td>
								<td class="fieldarea">';
    echo twilio_modeselect('step2_client_mode', $config);
    print '						</td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Text</strong></td>
								<td class="fieldarea"><textarea name="step2_client_text" rows="10" cols="80">' . $config['step2_client_text'] . '</textarea></td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Invalid Input Audio Mode</strong></td>
								<td class="fieldarea">';
    echo twilio_modeselect('step2_client_sorry_mode', $config);
    print '					</tr>
							<tr>
								<td class="fieldlabel"><strong>Invalid Input Text</strong></td>
								<td class="fieldarea"><textarea name="step2_client_sorry_text" rows="10" cols="80">' . $config['step2_client_sorry_text'] . '</textarea></td>
							</tr>
						</table>
						<p align="center"><input type="submit" value="Save Changes" /></p>
					</form>
					<br />
					<a name="variables"></a><h3>Step 2 Variables</h3>
					<div class="tablebg" align="center">
						<table class="datatable" cellspacing="1" cellpadding="1" width="50%">
							<tr><th>Variable</th><th>Provides</th></tr>
							
							<tr><td align="center">%FIRSTNAME%</td><td align="center">Clients Firstname</td></tr>
							<tr><td align="center">%LASTNAME%</td><td align="center">Clients Lastname</td></tr>
							<tr><td align="center">%COMPANY%</td><td align="center">Clients Company Name</td></tr>
							<tr><td align="center">%EMAIL%</td><td align="center">Clients Email</td></tr>
							<tr><td align="center">%ADDRESS1%</td><td align="center">Clients Address Line 1</td></tr>
							<tr><td align="center">%ADDRESS2%</td><td align="center">Clients Address Line 2</td></tr>
							<tr><td align="center">%CITY%</td><td align="center">Clients City</td></tr>
							<tr><td align="center">%STATE%</td><td align="center">Clients State</td></tr>
							<tr><td align="center">%POSTCODE%</td><td align="center">Clients Postcode</td></tr>
							<tr><td align="center">%PHONE%</td><td align="center">Clients Phone Number</td></tr>
							<tr><td align="center">%STATUS%</td><td align="center">Clients Account Status</td></tr>
							<tr><td align="center">%TICKET_TITLE%</td><td align="center">Tickets Title Text (only applicable for ticket mode)</td></tr>
							<tr><td align="center">%TICKET_URGENCY%</td><td align="center">Tickets Urgency (only applicable for ticket mode)</td></tr>
							<tr><td align="center">%TICKET_STATUS%</td><td align="center">Tickets Status (only applicable for ticket mode)</td></tr>
						</table>
					</div>
				</div>
			</div>
			<div id="tab1box" class="tabbox">
				<div id="tab_content">
					<h3>Phone Numbers</h3>
					<p align="left">
						<strong>Instructions:</strong> Enter the phone numbers below you wish to dial after the user has called the Twilio number. These will typically be support operators phone numbers.<br /><br />
					</p>
					<p align="left">
						<strong>Phone Number:</strong> Format: +12223334444. This is the number the user will be redirected to after following the phone prompts.<br />
						<strong>Timeout:</strong> This is the amount of time (in seconds) to wait before moving on to the next number. If the number has voicemail, its important that this number is lower than the amount of time before the user is redirected to VM.<br />
						<strong>Order:</strong> This is the order in which the numbers are dialed. Lower numbers are dialed first. Leaving this blank will default to "0" and therefore be called first.<br />
						<strong>Delete:</strong> Check this box to delete an existing number.<br />
					</p>
					<br />
					<form method="POST" action="' . $modulelink . '&last=1">
						<input type="hidden" name="_a" value="modnumbers" />
						<div class="tablebg" align="center">
							<table class="datatable" cellspacing="1" cellpadding="1" width="400">
								<tr>
									<th>Phone Number</th>
									<th>Timeout</th>
									<th>Order</th>
									<th>Delete</th>
								</tr>';
    foreach ($numbers as $key => $val) {
        $nid = $val['id'];
        print '					<tr>
									<td align="center"><input type="text" size="40" name="number[' . $nid . ']" value="' . $val['number'] . '" /></td>
									<td align="center"><input type="text" size="10" name="timeout[' . $nid . ']" value="' . $val['timeout'] . '" /></td>
									<td align="center"><input type="text" size="10" name="order[' . $nid . ']" value="' . $val['order'] . '" /></td>
									<td align="center">
										<input type="checkbox" name="delete[' . $nid . ']" value="1" />
										<input type="hidden" name="numberid[' . $nid . ']" value="' . $nid . '" />
									</td>
								</tr>';
    }
    print '						<tr>
									<td align="center"><input type="text" size="40" name="number[\'NEW\']" value="" /></td>
									<td align="center"><input type="text" size="10" name="timeout[\'NEW\']" value="" /></td>
									<td align="center"><input type="text" size="10" name="order[\'NEW\']" value="" /></td>
									<td><input type="hidden" name="numberid[\'NEW\']" value="NEW" /></td>
								</tr>
							</table>
						</div>
						<input type="submit" value="Save Changes" name="save" />
					</form>
				</div>
			</div>
			<div id="tab2box" class="tabbox">
				<div id="tab_content">
					<h3>Upload Audio Files</h3>
					<p align="left">
						<strong>Instructions:</strong> These files are used in place of the default Twilio text-to-speech engine. You can record your own voice, or hire a professional to record them for you.
					</p>
					<p align="left">
						<strong>Notes:</strong>
						<ul align="left">
							<li>- These files will ONLY be used if you have selected "Audio File" from the selection on the Configuration page.</li>
							<li>- Keep in mind that these files will have to be downloaded from your server, to Twilio, then streamed to the caller. Large files will likely cause delay in the system.</li>
							<li>- The max file size is set to 2MB, however, it is recommended that you keep the file sizes as small as possible. 72Kbps mono recordings will likely yield the best results.</li>
							<li>- ONLY MP3 files are supported. If you have your audio in another format, you\'ll need to convert it to MP3 before uploading.</li>
						</ul>
					</p>
					<br />
					<form method="POST" action="' . $modulelink . '&last=2" enctype="multipart/form-data">
						<input type="hidden" name="_a" value="uploadaudio" />
						<table class="form" width="50%" border="0" cellspacing="2" cellpadding="3" align="center">
							<tr>
								<td class="fieldlabel"><strong>Introduction</strong></td>
								<td class="fieldarea"><input type="file" name="intro_file" /></td>
								<td class="fieldarea" align="center"><a href="../modules/addons/twilio/calls/get_audio.php?f=intro_file" target="_blank"><img src="../modules/addons/twilio/images/play.png" /></a></td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Step 1 (Client)</strong></td>
								<td class="fieldarea"><input type="file" name="step1_client_file" /></td>
								<td class="fieldarea" align="center"><a href="../modules/addons/twilio/calls/get_audio.php?f=step1_client_file" target="_blank"><img src="../modules/addons/twilio/images/play.png" /></a></td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Step 1 (Ticket)</strong></td>
								<td class="fieldarea"><input type="file" name="step1_ticket_file" /></td>
								<td class="fieldarea" align="center"><a href="../modules/addons/twilio/calls/get_audio.php?f=step1_ticket_file" target="_blank"><img src="../modules/addons/twilio/images/play.png" /></a></td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Step 2 (Client)</strong></td>
								<td class="fieldarea"><input type="file" name="step2_client_file" /></td>
								<td class="fieldarea" align="center"><a href="../modules/addons/twilio/calls/get_audio.php?f=step2_client_file" target="_blank"><img src="../modules/addons/twilio/images/play.png" /></a></td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Step 2 (Client) - Invalid Input</strong></td>
								<td class="fieldarea"><input type="file" name="step2_client_sorry_file" /></td>
								<td class="fieldarea" align="center"><a href="../modules/addons/twilio/calls/get_audio.php?f=step2_client_sorry_file" target="_blank"><img src="../modules/addons/twilio/images/play.png" /></a></td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Step 2 (Ticket)</strong></td>
								<td class="fieldarea"><input type="file" name="step2_ticket_file" /></td>
								<td class="fieldarea" align="center"><a href="../modules/addons/twilio/calls/get_audio.php?f=step2_ticket_file" target="_blank"><img src="../modules/addons/twilio/images/play.png" /></a></td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Step 2 (Ticket) - Invalid Input</strong></td>
								<td class="fieldarea"><input type="file" name="step2_ticket_sorry_file" /></td>
								<td class="fieldarea" align="center"><a href="../modules/addons/twilio/calls/get_audio.php?f=step2_ticket_sorry_file" target="_blank"><img src="../modules/addons/twilio/images/play.png" /></a></td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>General Invalid Input</strong></td>
								<td class="fieldarea"><input type="file" name="invalid_request_file" /></td>
								<td class="fieldarea" align="center"><a href="../modules/addons/twilio/calls/get_audio.php?f=invalid_request_file" target="_blank"><img src="../modules/addons/twilio/images/play.png" /></a></td>
							</tr>
							<tr>
								<td class="fieldlabel"><strong>Voicemail</strong></td>
								<td class="fieldarea"><input type="file" name="voicemail_file" /></td>
								<td class="fieldarea" align="center"><a href="../modules/addons/twilio/calls/get_audio.php?f=voicemail_file" target="_blank"><img src="../modules/addons/twilio/images/play.png" /></a></td>
							</tr>
						</table>
						<p align="center">
							<input type="submit" value="Upload Files" />
						</p>
					</form>
					
				</div>
			</div>
		</div>';
}
Example #17
0
function mediacp_CreateAccount($params)
{
    global $debug;
    if (!empty($params['domain']) && is_numeric($params['domain'])) {
        $api['args']['portbase'] = $params['domain'];
        $api['args']['unique_id'] = $params['domain'];
    }
    if (!strstr($params['domain'], "terminated") && !empty($params['domain'])) {
        $return = "You have already created the account, Please Terminate the account first";
        return $return;
    }
    $api['path'] = $params['configoption2'];
    $api['rpc'] = "admin.user_create";
    $api['args']['auth'] = $params['configoption1'];
    $api['args']['username'] = trim($params['clientsdetails']['email']);
    $api['args']['hash'] = sha1($api['args']['username'] . mcp_getClientPassword($params['clientsdetails']['userid']));
    $api['args']['user_email'] = trim($params['clientsdetails']['email']);
    if (is_numeric($params['configoption15'])) {
        $api['args']['reseller_plan'] = $params['configoption15'];
    }
    $return = mediacp_api($api);
    if ($return['status'] != "success" && $return['error'] != "User account already exists") {
        return $return['error'];
    }
    $___url = parse_url($params['configoption2']);
    update_query("tblhosting", array("username" => $api['args']['username'], "password" => encrypt(mcp_getClientPassword($params['clientsdetails']['userid']))), array("id" => (int) $params['serviceid']));
    if ($params['configoption16'] == "No") {
        return "success";
    }
    if ($params['configoption4'] != "") {
        $api['args']['customfields']['servicetype'] = $params['configoption4'];
    }
    $result3 = select_query("tblhostingconfigoptions", "", array("relid" => (int) $params['serviceid']));
    while ($data3 = mysql_fetch_array($result3)) {
        $optionid = $data3['optionid'];
        $configid = $data3['configid'];
        $result2 = select_query("tblproductconfigoptions", "", array("id" => (int) $configid));
        $data2 = mysql_fetch_array($result2);
        $optionname = $data2['optionname'];
        $result2 = select_query("tblproductconfigoptionssub", "", array("id" => (int) $optionid));
        $data2 = mysql_fetch_array($result2);
        $optionvalue = $data2['optionname'];
        $optionvalue = str_replace("MB", "", $optionvalue);
        $optionvalue = str_replace("KB", "", $optionvalue);
        $optionvalue = str_replace("Kbps", "", $optionvalue);
        $optionvalue = trim($optionvalue);
        if ($optionvalue == "Yes") {
            $optionvalue = "enabled";
        } else {
            if ($optionvalue == "No") {
                $optionvalue = "disabled";
            } else {
                if (strtolower($optionvalue) == "unlimited") {
                    $optionvalue = "0";
                }
            }
        }
        if ($optionname == "Maximum Users") {
            $params['configoption5'] = $optionvalue;
        }
        if ($optionname == "Maximum Bit Rate" || $optionname == "Maximum Bitrate") {
            $params['configoption6'] = $optionvalue;
        }
        if ($optionname == "Bandwidth") {
            if (strstr($optionvalue, "GB")) {
                $optionvalue = str_replace("GB", "", $optionvalue * 1024);
            }
            if (strstr($optionvalue, "TB")) {
                $optionvalue = str_replace("TB", "", $optionvalue * 1024 * 1024);
            }
            $params['configoption7'] = $optionvalue;
        }
        if ($optionname == "Service Type") {
            if ($optionvalue == "Disabled" || $optionvalue == "") {
                $optionvalue == "";
            }
            if (strtolower($optionvalue) == "shoutcast") {
                $optionvalue = "shoutcast198";
            }
            if (strtolower($optionvalue) == "icecast") {
                $optionvalue = "icecast";
            }
            if (strstr($optionvalue, "Wowza Media Server")) {
                $optionvalue = "WowzaMedia";
            }
            if (strstr($optionvalue, "Windows Media Service")) {
                $optionvalue = "WowzaMedia";
            }
            if (strstr($optionvalue, "CDS Service")) {
                $optionvalue = "NoService";
            }
            $params['configoption5'] = $optionvalue;
        }
        if ($optionname == "Source") {
            if ($optionvalue == "Disabled" || $optionvalue == "") {
                $optionvalue == "";
            }
            $params['configoption8'] = $optionvalue;
        }
        if ($optionname == "Quota" || strstr($optionname, "Disk Quota")) {
            if (strstr($optionvalue, "MB")) {
                $optionvalue = str_replace("MB", "", $optionvalue);
            }
            if (strstr($optionvalue, "GB")) {
                $optionvalue = str_replace("GB", "", $optionvalue * 1024);
            }
            if (strstr($optionvalue, "TB")) {
                $optionvalue = str_replace("TB", "", $optionvalue * 1024 * 1024);
            }
            $params['configoption9'] = $optionvalue;
        }
        if ($optionname == "Port 80 Proxy") {
            $params['configoption11'] = $optionvalue;
        }
        if ($optionname == "MSN Service Control" || $optionname == "Messenger Service Control") {
            $params['configoption12'] = $optionvalue;
        }
        if ($optionname == "Wowza Media Type" || $optionname == "Flash Media Type") {
            if (strpos($optionvalue, "Shoutcast") !== FALSE) {
                $api['args']['customfields']['servicetype'] = "Shoutcast";
            }
            $api['args']['customfields']['servicetype'] = $optionvalue;
        }
        if ($optionname == "Source Reencode") {
            $api['args']['customfields']['ices_reencode'] = $optionvalue;
        }
        if ($optionname == "Permit Ondemand" || $optionname == "Ondemand Service") {
            $api['args']['customfields']['permit_ondemand'] = $optionvalue;
        }
        if ($optionname == "Ondemand Service") {
            $api['args']['customfields']['permit_ondemand'] = strtolower($optionvalue) == "allowed" ? 1 : 0;
        }
    }
    $api['path'] = $params['configoption2'];
    $api['rpc'] = "admin.service_create";
    $api['args']['rpc_extra'] = 1;
    $api['args']['auth'] = $params['configoption1'];
    $api['args']['plan'] = false;
    $api['args']['userid'] = $return['id'];
    $api['args']['password'] = mcp_getClientPassword($params['clientsdetails']['userid']);
    $api['args']['adminpassword'] = mcp_getClientPassword($params['clientsdetails']['userid']);
    $api['args']['plugin'] = $params['configoption3'];
    $api['args']['maxuser'] = $params['configoption5'];
    $api['args']['bitrate'] = $params['configoption6'];
    $api['args']['bandwidth'] = $params['configoption7'];
    $api['args']['sourceplugin'] = $params['configoption8'];
    $api['args']['quota'] = $params['configoption9'];
    $api['args']['proxy'] = $params['configoption11'];
    $api['args']['messengercontrol'] = $params['configoption12'];
    $api['args']['streamauth'] = $params['configoption14'];
    $__PPN = "Publish Point Name";
    $__POP = "Service Type";
    $__SL = "Public Hostname / IP and Port (Pull Only)";
    $__SUN = "Broadcasting Username";
    $__SPW = "Broadcasting Password";
    $SCLocation = "Shoutcast Address";
    if (isset($params['customfields'][$SCLocation])) {
        $api['args']['customfields']['shoutcast_address'] = $params['customfields'][$SCLocation];
    }
    if (isset($params['customfields'][$__PPN]) && 4 < strlen($params['customfields'][$__PPN])) {
        $api['args']['customfields']['publish_name'] = $params['customfields'][$__PPN];
        $api['args']['unique_id'] = $params['customfields'][$__PPN];
    }
    if (isset($params['customfields'][$__POP]) && strtolower($params['customfields'][$__POP]) == "pull") {
        if (isset($params['customfields'][$__SL]) && (substr($params['customfields'][$__SL], 0, 6) == "mms://" || substr($params['customfields'][$__SL], 0, 7) == "http://")) {
            $api['args']['customfields']['sourcelocation'] = $params['customfields'][$__SL];
        }
    }
    if (isset($params['customfields'][$__POP]) && strtolower($params['customfields'][$__POP]) == "ondemand") {
        $api['args']['customfields']['sourcelocation'] = "Ondemand:";
        $api['args']['customfields']['permit_ondemand'] = 1;
    }
    if (!empty($params['configoption13']) && $params['configoption13'] != "disabled") {
        $api['args']['expire'] = strtotime($params['configoption13']);
    }
    if (!empty($params['configoption10'])) {
        $api['args']['systemid'] = $params['configoption10'];
        $api['args']['system_id'] = $params['configoption10'];
    }
    $return = mediacp_api($api);
    if ($return['status'] != "success") {
        return $return['error'];
    }
    if ($params['configoption17'] == "enabled") {
        $fieldid = (int) get_query_val("tblcustomfields", "id", array("fieldname" => $__PPN, "relid" => $params['packageid']));
        $checkExistance = get_query_val("tblcustomfieldsvalues", "fieldid", array("fieldid" => $fieldid, "relid" => (int) $params['serviceid']));
        if (!$checkExistance) {
            insert_query("tblcustomfieldsvalues", array("fieldid" => $fieldid, "relid" => (int) $params['serviceid'], "value" => $return['serverData']['publish_name']));
        } else {
            update_query("tblcustomfieldsvalues", array("value" => $return['serverData']['publish_name']), array("fieldid" => $fieldid, "relid" => (int) $params['serviceid']));
        }
        $fieldid = (int) get_query_val("tblcustomfields", "id", array("fieldname" => $__SUN, "relid" => $params['packageid']));
        $checkExistance = get_query_val("tblcustomfieldsvalues", "fieldid", array("fieldid" => $fieldid, "relid" => (int) $params['serviceid']));
        if (!$checkExistance) {
            insert_query("tblcustomfieldsvalues", array("fieldid" => $fieldid, "relid" => (int) $params['serviceid'], "value" => $return['serverData']['windows_username']));
        } else {
            update_query("tblcustomfieldsvalues", array("value" => $return['serverData']['windows_username']), array("fieldid" => $fieldid, "relid" => (int) $params['serviceid']));
        }
        $fieldid = (int) get_query_val("tblcustomfields", "id", array("fieldname" => $__SPW, "relid" => $params['packageid']));
        $checkExistance = get_query_val("tblcustomfieldsvalues", "fieldid", array("fieldid" => $fieldid, "relid" => (int) $params['serviceid']));
        if (!$checkExistance) {
            insert_query("tblcustomfieldsvalues", array("fieldid" => $fieldid, "relid" => (int) $params['serviceid'], "value" => $return['serverData']['password']));
        } else {
            update_query("tblcustomfieldsvalues", array("value" => $return['serverData']['password']), array("fieldid" => $fieldid, "relid" => (int) $params['serviceid']));
        }
    }
    update_query("tblhosting", array("domain" => $___url['host'] . ":" . $return['portbase']), array("id" => (int) $params['serviceid']));
    return "success";
}
Example #18
0
 /**
  * Get an e-mailaddress for a WHMCS user
  * @param $user_id
  * @return bool|int
  */
 public static function get_whmcs_client_email_address($user_id)
 {
     return get_query_val('tblclients', 'email', array('id' => $user_id));
 }
Example #19
0
$urltowhmcs = $CONFIG['SystemURL'] . "/";
$whmcslogo = $CONFIG['LogoURL'];
$data = new AcquirerStatusRequest();
$transID = $_GET['trxid'];
$transID = str_pad($transID, 16, "0");
$data->setTransactionID($transID);
$rule = new ThinMPI();
$result = $rule->ProcessRequest($data);
if (!$result->isOK()) {
    $error_message = $result->getErrorMessage();
} else {
    if (!$result->isAuthenticated()) {
        $error_message = "Uw bestelling is helaas niet betaald, probeer het nog eens";
    } else {
        $transactionID = $result->getTransactionID();
        $invoiceid = get_query_val("mod_myideal", "invoiceid", array("transid" => $transactionID));
        $logdata = array("TransactionID" => $transactionID, "InvoiceID" => $invoiceid);
        if (!$invoiceid) {
            logTransaction("iDEAL", $logdata, "Invoice ID Not Found");
        }
        logTransaction("iDEAL", $logdata, "Successful");
        addInvoicePayment($invoiceid, $transactionID, "", "", "myideal");
        header("Location: " . $urltowhmcs . "viewinvoice.php?id=" . (int) $invoiceid . "&paymentsuccess=true");
        exit;
    }
}
if ($error_message) {
    echo "<html>\n<head>\n  <title> iDeal Payment Failed </title>\n  <meta http-equiv=\"refresh\" content=\"10; url=";
    echo $urltowhmcs;
    echo "clientarea.php?action=invoices\">\n</head>\n<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#0000FF\" vlink=\"#800080\" alink=\"#FF0000\">\n\n<center>\n\n<img src=\"";
    echo $whmcslogo;
Example #20
0
     $currency = getCurrency();
 } else {
     $client = "None";
 }
 $ticketinvoicelinks = array();
 foreach ($ticketids as $i => $ticketnum) {
     if ($ticketnum) {
         $ticketnum = get_query_val("tbltickets", "tid", array("tid" => $ticketnum));
         $ticketinvoicelinks[] = "description LIKE '%Ticket #" . $ticketnum . "%'";
         continue;
     }
 }
 $ticketinvoicesquery = !empty($ticketinvoicelinks) ? "(\".implode(' AND '," . $ticketinvoicelinks . ").\") OR " : "";
 $totalinvoiced = get_query_val("tblinvoices", "SUM(subtotal+tax+tax2)", "id IN (SELECT invoiceid FROM tblinvoiceitems WHERE description LIKE '%Project #" . $projectid . "%' OR " . $ticketinvoicesquery . " (type='Project' AND relid='" . $projectid . "'))");
 $totalinvoiced = $userid ? formatCurrency($totalinvoiced) : format_as_currency($totalinvoiced);
 $totalpaid = get_query_val("tblinvoices", "SUM(subtotal+tax+tax2)", "id IN (SELECT invoiceid FROM tblinvoiceitems WHERE description LIKE '%Project #" . $projectid . "%' OR " . $ticketinvoicesquery . " (type='Project' AND relid='" . $projectid . "')) AND status='Paid'");
 $totalpaid = $userid ? formatCurrency($totalpaid) : format_as_currency($totalpaid);
 $reportdata['drilldown'][$i]['tableheadings'] = array("Task Name", "Start Time", "Stop Time", "Duration", "Task Status");
 $timerresult = select_query("mod_projecttimes", "mod_projecttimes.start,mod_projecttimes.end,mod_projecttasks.task,mod_projecttasks.completed", array("mod_projecttimes.projectid" => $projectid), "", "", "", "mod_projecttasks ON mod_projecttimes.taskid = mod_projecttasks.id");
 while ($data2 = mysql_fetch_assoc($timerresult)) {
     $rowcount = $rowtotal = 0;
     $taskid = $data2['id'];
     $task = $data2['task'];
     $taskadminid = $data2['adminid'];
     $timerstart = $data2['start'];
     $timerend = $data2['end'];
     $duration = $timerend ? $timerend - $timerstart : 0;
     $taskadmin = getAdminName($taskadminid);
     $starttime = date("d/m/Y H:i:s ", $timerstart);
     $stoptime = date("d/m/Y H:i:s ", $timerend);
     $taskstatus = $data2['completed'] ? "Completed" : "Open";
Example #21
0
function closeTicket($id)
{
    global $whmcs;
    $status = get_query_val("tbltickets", "status", array("id" => $id));
    if ($status == "Closed") {
        return false;
    }
    if (defined("CLIENTAREA")) {
        addTicketLog($id, "Closed by Client");
    } else {
        if (defined("ADMINAREA")) {
            addTicketLog($id, "Status changed to Closed");
        } else {
            addTicketLog($id, "Ticket Auto Closed For Inactivity");
        }
    }
    update_query("tbltickets", array("status" => "Closed"), array("id" => $id));
    if ($whmcs->get_config("TicketFeedback")) {
        $feedbackcheck = get_query_val("tblticketfeedback", "id", array("ticketid" => $id));
        if (!$feedbackcheck) {
            sendMessage("Support Ticket Feedback Request", $id);
        }
    }
    run_hook("TicketClose", array("ticketid" => $id));
    return true;
}
Example #22
0
function disableAutoRenew($domainid)
{
    update_query("tbldomains", array("donotrenew" => "on"), array("id" => $domainid));
    $domainname = get_query_val("tbldomains", "domain", array("id" => $domainid));
    if ($_SESSION['adminid']) {
        logActivity("Admin Disabled Domain Auto Renew - Domain ID: " . $domainid . " - Domain: " . $domainname);
    } else {
        logActivity("Client Disabled Domain Auto Renew - Domain ID: " . $domainid . " - Domain: " . $domainname);
    }
    $result = select_query("tblinvoiceitems", "tblinvoiceitems.id,tblinvoiceitems.invoiceid", array("type" => "Domain", "relid" => $domainid, "status" => "Unpaid", "tblinvoices.userid" => $_SESSION['uid']), "", "", "", "tblinvoices ON tblinvoices.id=tblinvoiceitems.invoiceid");
    while ($data = mysql_fetch_array($result)) {
        $itemid = $data['id'];
        $invoiceid = $data['invoiceid'];
        $result2 = select_query("tblinvoiceitems", "COUNT(*)", array("invoiceid" => $invoiceid));
        $data = mysql_fetch_array($result2);
        $itemcount = $data[0];
        $otheritemcount = 0;
        if (1 < $itemcount) {
            $otheritemcount = get_query_val("tblinvoiceitems", "COUNT(*)", "invoiceid=" . (int) $invoiceid . (" AND id!=" . $itemid . " AND type NOT IN ('PromoHosting','PromoDomain','GroupDiscount')"));
        }
        if ($itemcount == 1 || $otheritemcount == 0) {
            update_query("tblinvoices", array("status" => "Cancelled"), array("id" => $invoiceid));
            logActivity("Cancelled Previous Domain Renewal Invoice - Invoice ID: " . $invoiceid . " - Domain: " . $domainname);
            run_hook("InvoiceCancelled", array("invoiceid" => $invoiceid));
        }
        delete_query("tblinvoiceitems", array("id" => $itemid));
        updateInvoiceTotal($invoiceid);
        logActivity("Removed Previous Domain Renewal Line Item - Invoice ID: " . $invoiceid . " - Domain: " . $domainname);
    }
}
Example #23
0
 echo "\">";
 echo $aInt->lang("orders", "ipban");
 echo "</a></td></tr>\n<tr><td class=\"fieldlabel\">";
 echo $aInt->lang("fields", "promocode");
 echo "</td><td class=\"fieldarea\">";
 if ($promocode) {
     if (strpos($promotype, "Percentage")) {
         echo $promocode . " - " . $promovalue . "% " . str_replace("Percentage", "", $promotype);
     } else {
         echo $promocode . " - " . formatCurrency($promovalue) . " " . str_replace("Fixed Amount", "", $promotype);
     }
     echo "<br />";
 }
 if (array_key_exists("bundleids", $orderdata) && is_array($orderdata['bundleids'])) {
     foreach ($orderdata['bundleids'] as $bid) {
         $bundlename = get_query_val("tblbundles", "name", array("id" => $bid));
         if (!$bundlename) {
             $bundlename = "Bundle Has Been Deleted";
         }
         echo "Bundle ID " . $bid . " - " . $bundlename . "<br />";
     }
 } else {
     if (!$promocode) {
         echo "None";
     }
 }
 echo "</td><td class=\"fieldlabel\">";
 echo $aInt->lang("fields", "affiliate");
 echo "</td><td class=\"fieldarea\" id=\"affiliatefield\">";
 $result = select_query("tblhosting", "id", array("orderid" => $id));
 $data = mysql_fetch_array($result);
Example #24
0
    $disklimit = $aInt->lang("global", "unlimited");
}
if ($bwlimit == "0") {
    $bwlimit = $aInt->lang("global", "unlimited");
}
$currency = getCurrency($userid);
$data = get_query_vals("tblcancelrequests", "id,type,reason", array("relid" => $id), "id", "DESC");
$cancelid = $data['id'];
$canceltype = $data['type'];
$autoterminatereason = $data['reason'];
$autoterminateendcycle = false;
if ($canceltype == "End of Billing Period") {
    $autoterminateendcycle = $cancelid ? true : false;
}
if (!$server) {
    $server = get_query_val("tblservers", "id", array("type" => $module, "active" => "1"));
    if ($server) {
        update_query("tblhosting", array("server" => $server), array("id" => $id));
    }
}
$jscode = "function doDeleteAddon(id) {\nif (confirm(\"" . $aInt->lang("addons", "areyousuredelete", 1) . "\")) {\nwindow.location='" . $PHP_SELF . "?userid=" . $userid . "&id=" . $id . "&action=deladdon&aid='+id+'" . generate_token("link") . "';\n}}\nfunction runModuleCommand(cmd,custom) {\n    \$(\"#mod\"+cmd).dialog(\"close\");\n\n    \$(\"#modcmdbtns\").css(\"filter\",\"alpha(opacity=20)\");\n    \$(\"#modcmdbtns\").css(\"-moz-opacity\",\"0.2\");\n    \$(\"#modcmdbtns\").css(\"-khtml-opacity\",\"0.2\");\n    \$(\"#modcmdbtns\").css(\"opacity\",\"0.2\");\n    var position = \$(\"#modcmdbtns\").position();\n\n    \$(\"#modcmdworking\").css(\"position\",\"absolute\");\n    \$(\"#modcmdworking\").css(\"top\",position.top);\n    \$(\"#modcmdworking\").css(\"left\",position.left);\n    \$(\"#modcmdworking\").css(\"padding\",\"9px 50px 0\");\n    \$(\"#modcmdworking\").fadeIn();\n\n    var reqstr = \"userid=" . $userid . "&id=" . $id . "&modop=\"+cmd+\"" . generate_token("link") . "\";\n    if (custom) reqstr += \"&ac=\"+custom;\n    else if (cmd==\"suspend\") reqstr += \"&suspreason=\"+encodeURIComponent(\$(\"#suspreason\").val())+\"&suspemail=\"+\$(\"#suspemail\").is(\":checked\");\n\n    \$.post(\"clientsservices.php\", reqstr,\n    function(data){\n        if (data.substr(0,9)==\"redirect|\") {\n            window.location = data.substr(9);\n        } else {\n            \$(\"#servicecontent\").html(data);\n        }\n    });\n\n}\n";
$aInt->jscode = $jscode;
$clientnotes = array();
$result = select_query("tblnotes", "tblnotes.*,(SELECT CONCAT(firstname,' ',lastname) FROM tbladmins WHERE tbladmins.id=tblnotes.adminid) AS adminuser", array("userid" => $userid, "sticky" => "1"), "modified", "DESC");
while ($data = mysql_fetch_assoc($result)) {
    $data['created'] = fromMySQLDate($data['created'], 1);
    $data['modified'] = fromMySQLDate($data['modified'], 1);
    $data['note'] = autoHyperLink(nl2br($data['note']));
    $clientnotes[] = $data;
}
if (count($clientnotes)) {
Example #25
0
function widget_system_overview($vars)
{
    global $whmcs, $_ADMINLANG;
    $title = $_ADMINLANG['home']['sysoverview'];
    if ($whmcs->get_req_var('getsystemoverview')) {
        $activeclients = get_query_val("tblclients", "COUNT(id)", "status='Active'");
        $totalclients = get_query_val("tblclients", "COUNT(id)", "");
        $clientsactive = $activeclients == 0 || $totalclients == 0 ? '0' : round($activeclients / $totalclients * 100, 0);
        $activeservices = get_query_val("tblhosting", "COUNT(id)", "domainstatus='Active'");
        $totalservices = get_query_val("tblhosting", "COUNT(id)", "");
        $servicesactive = $activeservices == 0 || $totalservices == 0 ? '0' : round($activeservices / $totalservices * 100, 0);
        $unpaidinvoices = get_query_val("tblinvoices", "COUNT(id)", "status='Unpaid'");
        $overdueinvoices = get_query_val("tblinvoices", "COUNT(id)", "status='Unpaid' AND duedate<'" . date("Ymd") . "'");
        $overduestatus = $overdueinvoices == 0 || $unpaidinvoices == 0 ? '0' : round($overdueinvoices / $unpaidinvoices * 100, 0);
        echo '
<table width="100%">
<tr>
    <td width="150">Clients</td>
    <td>
    <div class="percentbar">
    <div class="active" style="width:' . $clientsactive . '%">' . $clientsactive . '% Active</div>
    </div>
    </td>
    <td class="totals">' . $totalclients . '</td>
</tr>
<tr>
    <td>Services</td>
    <td>
    <div class="percentbar">
    <div class="active" style="width:' . $servicesactive . '%">' . $servicesactive . '% Active</div>
    </div>
    </td>
    <td class="totals">' . $totalservices . '</td>
</tr>
<tr>
    <td>Unpaid Invoices</td>
    <td>
    <div class="percentbar">
    <div class="overdue" style="width:' . $overduestatus . '%">' . $overduestatus . '% Overdue</div>
    </div>
    </td>
    <td class="totals">' . $unpaidinvoices . '</td>
</tr>
</table>
';
        exit;
    }
    $adminusername = get_query_val("tbladmins", "username", array("id" => $vars['adminid']));
    $lastlogin = get_query_vals("tbladminlog", "lastvisit,ipaddress", array("adminusername" => $adminusername), "lastvisit", "DESC", "1,1");
    $lastlogindate = $lastlogin[0] ? fromMySQLDate($lastlogin[0], true) : '(None Recorded)';
    $lastloginip = $lastlogin[1] ? $lastlogin[1] : '-';
    $content = '
<style>
#systemoverviewstats {
    display: none;
}
#systemoverviewstats div.percentbar {
    width: 100%;
    height: 24px;
    border: 1px solid #ccc;
    background-color: #efefef;
}
#systemoverviewstats div.percentbar div.active {
    height: 24px;
    line-height: 24px;
    background-color: #84B429;
    color: #fff;
    font-weight: bold;
    text-align: center;
    overflow: hidden;
}
#systemoverviewstats div.percentbar div.overdue {
    height: 24px;
    line-height: 24px;
    background-color: #cc0000;
    color: #fff;
    font-weight: bold;
    text-align: center;
}
#systemoverviewstats td {
    text-align: center;
    font-weight: bold;
    height: 35px;
}
.lastlogin {
    margin-bottom:5px;
    padding:3px;
    text-align: center;
}
</style>

<div id="systemoverviewstats">' . $vars['loading'] . '</div>

<div class="lastlogin">' . $_ADMINLANG['home']['lastlogin'] . ': <strong>' . $lastlogindate . '</strong> ' . $_ADMINLANG['home']['lastloginip'] . ' <strong>' . $lastloginip . '</strong></div>

';
    $statusfilter = array();
    $result = select_query("tblticketstatuses", "title", array("showawaiting" => "1"));
    while ($data = mysql_fetch_array($result)) {
        $statusfilter[] = $data[0];
    }
    $result = full_query("SELECT COUNT(*) FROM tbltickets WHERE status IN (" . db_build_in_array($statusfilter) . ")");
    $data = mysql_fetch_array($result);
    $ticketsawaitingreply = $data[0];
    $result = full_query("SELECT COUNT(*) FROM tblcancelrequests INNER JOIN tblhosting ON tblhosting.id=tblcancelrequests.relid WHERE (tblhosting.domainstatus!='Cancelled' AND tblhosting.domainstatus!='Terminated')");
    $data = mysql_fetch_array($result);
    $cancellationrequests = $data[0];
    $result = full_query("SELECT COUNT(*) FROM tbltodolist WHERE status!='Completed' AND status!='Postponed' AND duedate<='" . date("Y-m-d") . "'");
    $data = mysql_fetch_array($result);
    $todoitemsdue = $data[0];
    $result = full_query("SELECT COUNT(*) FROM tblnetworkissues WHERE status!='Scheduled' AND status!='Resolved'");
    $data = mysql_fetch_array($result);
    $opennetworkissues = $data[0];
    $jquerycode = 'jQuery.post("index.php", { getsystemoverview: 1 },
    function(data){
        jQuery("#systemoverviewstats").html(data);
        jQuery("#systemoverviewstats").slideDown();
        jQuery("#sysoverviewbanner").html("<div style=\\"margin:0 0 -5px 0;padding: 10px;background-color: #FBEEEB;border: 1px dashed #cc0000;font-weight: bold;color: #cc0000;font-size:14px;text-align: center;-moz-border-radius: 10px;-webkit-border-radius: 10px;-o-border-radius: 10px;border-radius: 10px;\\">' . $_ADMINLANG['global']['attentionitems'] . ': &nbsp; <a href=\\"supporttickets.php\\">' . $ticketsawaitingreply . ' ' . $_ADMINLANG['stats']['ticketsawaitingreply'] . '</a> &nbsp;-&nbsp; <a href=\\"cancelrequests.php\\">' . $cancellationrequests . ' ' . $_ADMINLANG['stats']['pendingcancellations'] . '</a> &nbsp;-&nbsp; <a href=\\"todolist.php\\">' . $todoitemsdue . ' ' . $_ADMINLANG['stats']['todoitemsdue'] . '</a> &nbsp;-&nbsp; <a href=\\"networkissues.php\\">' . $opennetworkissues . ' ' . $_ADMINLANG['stats']['opennetworkissues'] . '</a></div>");
});';
    return array('title' => $title, 'content' => $content, 'jquerycode' => $jquerycode);
}
Example #26
0
        $where = "WHERE did='" . mysql_real_escape_string($deptid) . "'";
    }
    $result = full_query("SELECT status, COUNT(*) AS count FROM tbltickets " . $where . " GROUP BY status");
    while ($data = mysql_fetch_array($result)) {
        $statuses[$data['status']] = $data['count'];
    }
    foreach ($statuses as $status => $ticketcount) {
        $apiresults['supportstatuses']['status'][] = array("title" => $status, "count" => $ticketcount);
    }
    $deptartments = array();
    $result = full_query("SELECT id, name FROM tblticketdepartments");
    while ($data = mysql_fetch_assoc($result)) {
        $deptartments[$data['id']] = $data['name'];
    }
    foreach ($deptartments as $deptid => $deptname) {
        $apiresults['supportdepartments']['department'][] = array("id" => $deptid, "name" => $deptname, "count" => get_query_val("tbltickets", "COUNT(id)", array("did" => $deptid)));
    }
    $gateways = array();
    $result = select_query("tblpaymentgateways", "gateway,value", array("setting" => "name"));
    while ($data = mysql_fetch_assoc($result)) {
        $gateways[$data['gateway']] = $data['value'];
    }
    if (!function_exists("getGatewaysArray")) {
        require ROOTDIR . "/includes/gatewayfunctions.php";
    }
    $paymentmethods = getGatewaysArray();
    foreach ($paymentmethods as $module => $name) {
        $apiresults['paymentmethods']['paymentmethod'][] = array("module" => $module, "displayname" => $name);
    }
}
$apiresults['requesttime'] = date("Y-m-d H:i:s");
Example #27
0
if (!defined("WHMCS")) {
    die("This file cannot be accessed directly");
}
$reportdata["title"] = "New Customers";
$reportdata["description"] = "This report shows the total number of new customers, orders and complete orders and compares each of these to the previous year on the graph.";
$reportdata["tableheadings"] = array("Month", "New Signups", "Orders Placed", "Orders Completed");
for ($rawmonth = 1; $rawmonth <= 12; $rawmonth++) {
    $year2 = $year - 1;
    $month = str_pad($rawmonth, 2, 0, STR_PAD_LEFT);
    $newsignups = get_query_val("tblclients", "COUNT(*)", "datecreated LIKE '{$year}-{$month}-%'");
    $totalorders = get_query_val("tblorders", "COUNT(*)", "date LIKE '{$year}-{$month}-%'");
    $completedorders = get_query_val("tblorders", "COUNT(*)", "date LIKE '{$year}-{$month}-%' AND status='Active'");
    $newsignups2 = get_query_val("tblclients", "COUNT(*)", "datecreated LIKE '{$year2}-{$month}-%'");
    $totalorders2 = get_query_val("tblorders", "COUNT(*)", "date LIKE '{$year2}-{$month}-%'");
    $completedorders2 = get_query_val("tblorders", "COUNT(*)", "date LIKE '{$year2}-{$month}-%' AND status='Active'");
    $reportdata["tablevalues"][] = array($months[$rawmonth] . ' ' . $year, $newsignups, $totalorders, $completedorders);
    if (!$show || $show == "signups") {
        $chartdata['rows'][] = array('c' => array(array('v' => $months[$rawmonth]), array('v' => (int) $newsignups), array('v' => (int) $newsignups2)));
    }
    if ($show == "orders") {
        $chartdata['rows'][] = array('c' => array(array('v' => $months[$rawmonth]), array('v' => (int) $totalorders), array('v' => (int) $totalorders2)));
    }
    if ($show == "orderscompleted") {
        $chartdata['rows'][] = array('c' => array(array('v' => $months[$rawmonth]), array('v' => (int) $completedorders), array('v' => (int) $completedorders2)));
    }
}
$chartdata['cols'][] = array('label' => 'Month', 'type' => 'string');
$chartdata['cols'][] = array('label' => $year, 'type' => 'number');
$chartdata['cols'][] = array('label' => $year2, 'type' => 'number');
$args = array();
Example #28
0
}
if ($sub == "savegroup") {
    check_token("WHMCS.admin.default");
    checkPermission("Manage Product Groups");
    $disabledgateways = array();
    $gateways2 = getGatewaysArray();
    foreach ($gateways2 as $gateway => $gwname) {
        if (!$gateways[$gateway]) {
            $disabledgateways[] = $gateway;
            continue;
        }
    }
    if ($ids) {
        update_query("tblproductgroups", array("name" => $name, "orderfrmtpl" => $orderfrmtpl, "disabledgateways" => implode(",", $disabledgateways), "hidden" => $hidden), array("id" => $ids));
    } else {
        insert_query("tblproductgroups", array("name" => $name, "orderfrmtpl" => $orderfrmtpl, "disabledgateways" => implode(",", $disabledgateways), "hidden" => $hidden, "order" => get_query_val("tblproductgroups", "`order`", "", "order", "DESC") + 1));
    }
    redir();
}
if ($sub == "deletegroup") {
    check_token("WHMCS.admin.default");
    checkPermission("Manage Product Groups");
    delete_query("tblproductgroups", array("id" => $id));
    redir();
}
if ($sub == "delete") {
    check_token("WHMCS.admin.default");
    checkPermission("Delete Products/Services");
    run_hook("ProductDelete", array("pid" => $id));
    delete_query("tblproducts", array("id" => $id));
    delete_query("tblproductconfiglinks", array("pid" => $id));
Example #29
0
 *
 * @ Version  : 5.2.15
 * @ Author   : MTIMER
 * @ Release on : 2013-12-24
 * @ Website  : http://www.mtimer.cn
 *
 **/
if (!defined("WHMCS")) {
    exit("This file cannot be accessed directly");
}
$id = get_query_val("tbltodolist", "id", array("id" => $itemid));
if (!$itemid) {
    $apiresults = array("result" => "error", "message" => "TODO Item ID Not Found");
    return null;
}
$adminid = get_query_val("tbladmins", "id", array("id" => $adminid));
if (!$adminid) {
    $apiresults = array("result" => "error", "message" => "Admin ID Not Found");
    return null;
}
$todoarray = array();
if ($date) {
    $todoarray['date'] = toMySQLDate($date);
}
if ($title) {
    $todoarray['title'] = $title;
}
if ($description) {
    $todoarray['description'] = $description;
}
if ($adminid) {
Example #30
0
function oath_output($vars)
{
    if ($_GET['qr']) {
        require_once './../modules/addons/oath/phpqrcode/qrlib.php';
        $company = get_query_val('tblconfiguration', 'value', "setting = 'CompanyName'");
        QRcode::png('otpauth://totp/' . urlencode(str_replace(' ', '', $company)) . 'Admin?secret=' . $_GET['secret']);
        exit(0);
    }
    echo '<div style="text-align: center;">';
    $secret = get_query_val('mod_oath_admin', 'secret', "adminid = '{$_SESSION['adminid']}'");
    require_once './../modules/addons/oath/GoogleAuthenticator.php';
    $gauth = new PHPGangsta_GoogleAuthenticator();
    if ($vars['enable_admins'] == 'No') {
        echo 'Two-factor authentication is currently disabled for administrators.';
    } elseif (!$secret && $_POST['enable']) {
        if ($_POST['secret']) {
            if ($gauth->verifyCode($_POST['secret'], $_POST['code'], $vars['discrepancy'])) {
                insert_query('mod_oath_admin', array('adminid' => $_SESSION['adminid'], 'secret' => $_POST['secret']));
                $_SESSION['twofactoradmin'] = $_SESSION['adminid'];
                header('Location: ' . $vars['modulelink']);
                exit(0);
            } else {
                echo '<p><b>Your code was incorrect.</b></p>';
                $secret = $_POST['secret'];
            }
        } else {
            $secret = $gauth->createSecret();
        }
        echo '<p>Please scan this QR code with your mobile authenticator app.</p>';
        echo '<img src="' . $vars['modulelink'] . '&qr=1&secret=' . $secret . '" />';
        echo '<p>If you are unable to scan, use this secret:<br />' . $secret . '</p>';
        echo '<form method="post" action="' . $vars['modulelink'] . '">';
        echo '<input type="hidden" name="secret" value="' . $secret . '" />';
        echo '<input type="text" name="code" placeholder="Enter your code" autocomplete="off" /><br /><br />';
        echo '<input type="submit" name="enable" value="Verify Code" class="btn btn-primary" />';
        echo '</form>';
    } elseif (!$secret && $vars['enable_admins'] == 'Required') {
        echo '<b>You must enable two-factor authentication to proceed.</b><br /><br />';
        echo '<form method="post" action="' . $vars['modulelink'] . '"><input type="submit" name="enable" value="Enable Two-Factor Authentication" class="btn btn-primary" /></form>';
    } elseif ($secret && $_SESSION['twofactoradmin'] != $_SESSION['adminid']) {
        if ($_POST['code']) {
            if ($gauth->verifyCode($secret, $_POST['code'], $vars['discrepancy'])) {
                $_SESSION['twofactoradmin'] = $_SESSION['adminid'];
                $redirectURI = !empty($_SESSION['original_request_uri']) ? htmlspecialchars_decode($_SESSION['original_request_uri']) : 'index.php';
                header('Location: ' . $redirectURI);
                unset($_SESSION['original_request_uri']);
                exit(0);
            } else {
                echo '<p style="color: red;"><b>Your code was incorrect.</b></p>';
            }
        }
        echo '<p>Please enter the code generated by your mobile authenticator app.</p>';
        echo '<form method="post" action="' . $vars['modulelink'] . '">';
        echo '<input type="text" name="code" placeholder="Enter your code" autocomplete="off" /><br /><br />';
        echo '<input type="submit" name="enable" value="Validate Login" class="btn btn-primary" />';
        echo '</form>';
    } elseif ($secret && $_POST['disable']) {
        full_query("DELETE FROM `mod_oath_admin` WHERE adminid = '{$_SESSION['adminid']}'");
        unset($_SESSION['twofactoradmin']);
        header('Location: ' . $vars['modulelink']);
        exit(0);
    } elseif ($secret) {
        echo '<p>You have two-factor authentication enabled.</p>';
        echo '<form method="post" action="' . $vars['modulelink'] . '"><input type="submit" name="disable" value="Disable Two-Factor Authentication" class="btn btn-danger" /></form>';
    } else {
        echo '<p>You do not have two-factor authentication enabled.</p>';
        echo '<form method="post" action="' . $vars['modulelink'] . '"><input type="submit" name="enable" value="Enable Two-Factor Authentication" class="btn btn-primary" /></form>';
    }
    echo '</div>';
}