当前位置: 首页>>代码示例>>PHP>>正文


PHP Web::post方法代码示例

本文整理汇总了PHP中Web::post方法的典型用法代码示例。如果您正苦于以下问题:PHP Web::post方法的具体用法?PHP Web::post怎么用?PHP Web::post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Web的用法示例。


在下文中一共展示了Web::post方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: function

$app->post("/update", function () use($app) {
    if (!$app->authed()) {
        $app->makeError("Access denied");
        return;
    }
    $body = $app->request()->getBody();
    $qres = mysql_query("SELECT s.* FROM `tblservers` s WHERE s.`type` = 'cpanel' and s.`disabled` = 0;");
    if ($qres === FALSE) {
        $app->makeError("Unable to get list of cPanel servers");
        return;
    }
    $servers = array();
    while (($row = mysql_fetch_assoc($qres)) !== FALSE) {
        $servers[] = array("id" => intval($row["id"]), "name" => $row["name"], "hostname" => $row["hostname"], "username" => $row["username"], "accesshash" => $row["accesshash"]);
    }
    $plan = $body["plan"];
    $changes = array();
    // Update each WHM package
    foreach ($servers as $server) {
        $cpanel = new \Gufy\CpanelPhp\Cpanel(array("host" => "https://" . $server["hostname"] . ":2087", "username" => $server["username"], "password" => $server["accesshash"], "auth_type" => "hash"));
        $package = $cpanel->getpkginfo(array("pkg" => $plan["name"], "api.version" => 1));
        if ($package["metadata"]["result"] !== 1) {
            continue;
        }
        $package = $package["data"]["pkg"];
        $edits = array();
        if ($plan["limits"]["overage"] == 1) {
            if ($package["BWLIMIT"]) {
                $edits["bwlimit"] = "unlimited";
            }
            if ($package["QUOTA"]) {
                $edits["quota"] = "unlimited";
            }
        } else {
            if ($package["BWLIMIT"] != $plan["limits"]["bandwidth"]) {
                $edits["bwlimit"] = $plan["limits"]["bandwidth"];
            }
            if ($package["QUOTA"] != $plan["limits"]["disk"]) {
                $edits["quota"] = $plan["limits"]["disk"];
            }
        }
        if (count($edits) > 0) {
            $keys = array_keys($edits);
            $edits["name"] = $plan["name"];
            $edits["api.version"] = 1;
            $result = $cpanel->editpkg($edits);
            if ($result["metadata"]["result"] !== 1) {
                $app->makeError($result);
                continue;
            }
            $changes[] = $plan["name"] . " on " . $server["hostname"] . " updated: " . implode(",", $keys);
        }
    }
    // Update WHMCS
    $uPlanId = intval($plan["id"]);
    $uDisk = intval($plan["limits"]["disk"]);
    $uBw = intval($plan["limits"]["bandwidth"]);
    $uDesc = mysql_real_escape_string($plan["description"]);
    $uOverages = $plan["limits"]["overage"] == 1 ? "1,MB,MB" : "";
    $update = mysql_query("UPDATE tblproducts SET configoption3 = '{$uDisk}', configoption5 = '{$uBw}', description = '{$uDesc}', overagesenabled = '{$uOverages}', overagesdisklimit = {$uDisk}, overagesbwlimit = {$uBw} WHERE id = {$uPlanId}");
    if ($update === FALSE) {
        $changes[] = "*** WARNING: Changes could not be synced to WHMCS - please resolve this manually! ***";
        $changes[] = mysql_error();
    }
    echo json_encode($changes);
});
开发者ID:arktisma,项目名称:whmcs_whmpackageeditor,代码行数:66,代码来源:index.php


注:本文中的Web::post方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。