Exemplo n.º 1
0
function child_render($param)
{
    global $g_page, $g_cfg;
    $g_page["frame"] = "site_admin/frame.html";
    if (!http_user_auth("admin", "admin")) {
        return redirect("/");
    }
    if (isset($param[1]) && $param[1] == "switch_status") {
        list($cname, $p) = [$_GET["name"], $_GET["p"]];
        if ($p == "close") {
            dbupdate("sys_variations", [], ["test" => $cname], ["completed" => "now()"]);
        }
        return redirect("/stats/multivariants");
    }
    $q = gettable("select * from sys_variations where completed is null");
    $t = [];
    foreach ($q as $row) {
        if (!isset($t[$row["test"]])) {
            $t[$row["test"]] = [];
        }
        if (!isset($t[$row["test"]][$row["variation"]])) {
            $t[$row["test"]][$row["variation"]] = ["goals" => []];
        }
        $t[$row["test"]][$row["variation"]]["content"] = substr($row["content"], 0, 256);
        $cm = new Variant($row["test"]);
        $t[$row["test"]][$row["variation"]]["enrolled"] = $cm->get() == $row["variation"] ? 1 : 0;
        $t[$row["test"]][$row["variation"]]["variation"] = $row["variation"];
        $cv = [];
        $cgoal = $row;
        $cgoal["pc"] = $row["sample"] == 0 ? "N/A" : round($row["conversion"] / $row["sample"] * 100, 2);
        $t[$row["test"]][$row["variation"]]["goals"][] = $cgoal;
        $t[$row["test"]][$row["variation"]] = update($t[$row["test"]][$row["variation"]], $cv);
    }
    $res = [];
    foreach ($t as $name => $row) {
        $cm = [];
        foreach ($t[$name] as $varname => $cvar) {
            uasort($cvar["goals"], function ($a, $b) {
                global $g_mv_goals;
                if (($i = array_search($a["goal"], $g_mv_goals)) === false) {
                    return -1;
                }
                if (($j = array_search($b["goal"], $g_mv_goals)) === false) {
                    return -1;
                }
                if ($i == $j) {
                    return 0;
                }
                return $i > $j ? 1 : -1;
            });
            $cm[] = $cvar;
        }
        $res[] = ["test" => $name, "var" => $cm];
    }
    // print_r($res); exit;
    $scr = new Scriptor("site_admin/multivariants.html", ["tests" => $res]);
    return $scr->result();
}
Exemplo n.º 2
0
    echo "Invalid ID, please try again and make sure the ID is a valid sid in the database";
    exit;
}
require 'functions.php';
if (isset($_POST['import']) and is_numeric($sid)) {
    $import = $_POST['import'];
    $arr = explode(',', $import);
    $run = srvspecsimp($arr['0'], $arr['1'], $arr['2'], $arr['3'], $arr['4'], $arr['5'], $arr['6'], $arr['7'], $sid);
    if ($run == true) {
        echo "<div class=\"view-messages\">Import Successful!</div>";
    } else {
        echo "<div class=\"view-messages\">Import Failed.</div>";
    }
}
if (isset($_POST['name']) and is_numeric($sid)) {
    $run = dbupdate($_POST['name'], $_POST['provider'], $_POST['city'], $_POST['state'], $_POST['country'], $_POST['datacenter'], $_POST['cost'], $_POST['cycle'], $_POST['start'], $_POST['due'], $_POST['ram'], $_POST['swap'], $_POST['cpu'], $_POST['cpunum'], $_POST['cpuclock'], $_POST['bw'], $_POST['port'], $_POST['disk'], $_POST['disktype'], $_POST['ipv4'], $_POST['ipv6'], $_POST['notes'], $_POST['services'], $sid);
    if ($run == true) {
        echo "<div class=\"view-messages\">Edit Success!</div>";
    } else {
        echo "<div class=\"view-messages\">Edit Failed.</div>";
    }
}
$db = new SQLite3('ktoys.db3');
$result = $db->query("SELECT * FROM services WHERE sid='{$sid}'") or die('Query failed');
$cnt = $result->fetchArray();
$cnt = $cnt['sid'];
if ($cnt <= '0') {
    echo "Invalid ID, please try again and make sure the ID is a valid sid in the database";
    exit;
}
$result = $db->query("SELECT * FROM services WHERE sid='{$sid}'") or die('Query failed');
Exemplo n.º 3
0
 function update_password()
 {
     $username = getgpc("username");
     $old_password = getgpc("old_password");
     $new_password = getgpc("new_password");
     $new_password1 = getgpc("new_password1");
     $data = array();
     $md5salt = $this->config->item("md5salt");
     if ($username) {
         //
         $res = fetch_one_array("select * from " . dbtable("admin_user") . " where username='******'");
         if (!$res) {
             alert("错误,找不到该用户");
         } elseif ($res["password"] != md5($md5salt . $old_password)) {
             alert("输入旧密码不正确!");
         }
     }
     if (empty($old_password)) {
         alert("请输入旧密码");
     }
     if (empty($new_password)) {
         alert("请输入新密码");
     }
     if (empty($new_password1)) {
         alert("请输入确认密码");
     }
     if ($old_password == $new_password) {
         alert("请输入旧密码与新密码一样");
     }
     if ($new_password != $new_password1) {
         alert("请输入新密码与确认密码不一致");
     } else {
         $updata['password'] = md5($md5salt . $new_password);
         dbupdate("admin_user", $updata, array('username' => $username));
         // echo" <script language='javascript'>this.close();alert('修改密码成功,请记住新密码哟!');</script>";
         alert("修改密码成功,请记住新密码哟!", "admin.php?mod=login");
     }
     // $this->db->update('admin_user', $updata);
 }
Exemplo n.º 4
0
function variant_recalculate()
{
    global $g_mv_goals, $g_mv_tests;
    $res = [];
    foreach ($g_mv_tests as $row) {
        $res[$row["test"] . "|" . $row["variation"] . "|" . $row["goal"] . "|sample"] = [];
        $res[$row["test"] . "|" . $row["variation"] . "|" . $row["goal"] . "|conversion"] = [];
        $res[$row["test"] . "|" . $row["variation"] . "|" . $row["goal"] . "|start_log_id"] = $row["start_log_id"];
    }
    // print_r($res); exit;
    // add sessions
    $q = gettable("select * from sys_sessions where ishuman = 1");
    session_start();
    foreach ($q as $row) {
        foreach (array_keys($_SESSION) as $ckeys) {
            unset($_SESSION[$ckeys]);
        }
        if (!session_decode($row["session_data"])) {
            internal_error("Unable to unserialize: " . $row["session_data"]);
        }
        $res = variant_recalculate_identity($res, $_SESSION);
    }
    // add users
    $q = gettable("select * from usr_users");
    foreach ($q as $row) {
        $srow = json_decode($row["session_data"], true);
        if ($srow == null) {
            continue;
        }
        $nrow = json_decode($row["usr_notes"], true);
        if ($nrow == null) {
            continue;
        }
        if (isset($nrow["_mg_cancellation"])) {
            $srow["_mg_cancellation"] = intval($nrow["_mg_cancellation"]);
        }
        $res = variant_recalculate_identity($res, $srow);
    }
    // print_r($g_mv_tests ); exit;
    $ckeys = array_keys($res);
    foreach ($g_mv_tests as $row) {
        $sample = count(array_unique($res[$row["test"] . "|" . $row["variation"] . "|" . $row["goal"] . "|sample"]));
        $conv = count(array_unique($res[$row["test"] . "|" . $row["variation"] . "|" . $row["goal"] . "|conversion"]));
        $cwhere = update([], $row, ["test", "variation", "goal"]);
        dbupdate("sys_variations", ["sample" => $sample, "conversion" => $conv], $cwhere);
    }
}
Exemplo n.º 5
0
 public function saveedit_area()
 {
     //保存产品
     $id = getgpc("id");
     if ($id) {
         $res = fetch_one_array("select * from " . dbtable("joininfo_area") . " where id ='" . $id . "' ");
         if (!$res) {
             alert("错误,没有找到该数据", "");
         }
     }
     $name = getgpc("name");
     $tel = getgpc("tel");
     $email = getgpc("email");
     $join_name = getgpc("join_name");
     $area = getgpc("area");
     $displayorder = intval(getgpc("displayorder"));
     $status = intval(getgpc("status"));
     $indata = array("name" => $name, "join_name" => $join_name, "tel" => $tel, "area" => $area, "email" => $email, "displayorder" => $displayorder, "status" => $status);
     if (!$id) {
         $indata["gtime"] = date("Y-m-d H:i:s");
         dbinsert("joininfo_area", $indata);
     } else {
         $indata["uptime"] = date("Y-m-d H:i:s");
         dbupdate("joininfo_area", $indata, array('id' => $id));
     }
     js_alert("保存成功", "top.location.href='?mod=joininfo&act=area'");
 }
Exemplo n.º 6
0
 function saveadd()
 {
     //保存新增新闻
     $id = trim(getgpc("id"));
     $title = trim(getgpc("title"));
     $en_title = trim(getgpc("en_title"));
     $comfrom = getgpc("comfrom");
     $intr = getgpc("intr");
     $content_img1 = getgpc("content_img1");
     $content_img2 = getgpc("content_img2");
     $content_img3 = getgpc("content_img3");
     $content_img4 = getgpc("content_img4");
     $showtime = getgpc("showtime");
     $showtime = $showtime ? $showtime : date("Y-m-d H:i:s");
     $content = getgpc("content");
     $imgurl = trim(getgpc("imgurl"));
     $tags = trim(getgpc("tags"));
     $iskv = intval(getgpc("iskv"));
     $istop = intval(getgpc("istop"));
     $displayorder = intval(getgpc("displayorder"));
     $status = intval(getgpc("status"));
     if (!$title) {
         js_alert("请填写标题");
     }
     if (!$intr) {
         js_alert("请填写简介");
     }
     if (!$status) {
         js_alert("请选择状态");
     }
     //数据正常,入库
     $data = array('title' => $title, 'en_title' => $en_title, 'imgurl' => $imgurl, 'showtime' => $showtime, 'intr' => $intr, 'content_img1' => $content_img1, 'content_img2' => $content_img2, 'content_img3' => $content_img3, 'content_img4' => $content_img4, 'content' => $content, 'tags' => $tags, 'gtime' => date("Y-m-d H:i:s"), 'iskv' => $iskv, 'istop' => $istop, 'displayorder' => $displayorder, 'status' => $status);
     if (!$id) {
         $this->db->insert('news', $data);
         $id = $this->db->insert_id();
     } else {
         dbupdate("news", $data, array('id' => $id));
     }
     if ($iskv) {
         $upsql = "update " . dbtable("news") . " set iskv='0' where id!='" . $id . "'";
         $this->db->query($upsql);
     }
     js_alert("保存成功", "top.location.href='?mod=news'");
 }
Exemplo n.º 7
0
 function update()
 {
     //	 	$res1=fetch_one_array("select * from ".dbtable("prize")." where prize_value='5' and tel!='' order by gtime desc limit 1");
     //		$now_date=time();
     //	 	$prize_date=strtotime($res1['gtime']);
     //		$sign1=false;
     //		if($now_date-$prize_date>86400*3)
     //		{
     //			$sign1=true;
     //	 	}
     //	$this_date=date("Y-m-d");
     // 	$prizenum5=fetch_one_array("select count(*) as num from ".dbtable("prize")." where prize_value='4' and tel!='' and prize_date='$this_date'");
     //	$sign5=false;
     // 	if($prizenum5['num']<=20)
     // 	{
     //		$sign5=true;
     // 	}
     $list = fetch_array("select * from " . dbtable("prize") . " where status='0' and prize_no='SL201410000'");
     foreach ($list as $row) {
         $id = $row['id'];
         $prize_no = prize_no("prize_no", "prize", "SL");
         dbupdate("prize", array("prize_no" => $prize_no), "id ='" . $id . "'");
         echo "ID:", $id, "中奖代码:", $prize_no, "<br>";
     }
 }
Exemplo n.º 8
0
 public function saveedit()
 {
     //保存产品
     $id = getgpc("id");
     if ($id) {
         $res = fetch_one_array("select * from " . dbtable("faq") . " where id ='" . $id . "' ");
         if (!$res) {
             alert("错误,没有找到该数据", "");
         }
     }
     $name = getgpc("name");
     $tel = getgpc("tel");
     $email = getgpc("email");
     $question = getgpc("question");
     $displayorder = intval(getgpc("displayorder"));
     $status = intval(getgpc("status"));
     $indata = array("name" => $name, "tel" => $tel, "email" => $email, "question" => $question, "reply_sign" => 1, "displayorder" => $displayorder, "status" => $status);
     if (!$id) {
         $indata["gtime"] = date("Y-m-d H:i:s");
         dbinsert("faq", $indata);
     } else {
         $indata["reply"] = getgpc("reply");
         $indata["reply_sign"] = 2;
         $indata["uptime"] = date("Y-m-d H:i:s");
         dbupdate("faq", $indata, array('id' => $id));
     }
     js_alert("保存成功", "top.location.href='?mod=faq&act=index'");
 }
Exemplo n.º 9
0
 public function save_employment_content()
 {
     //保存产品
     $id = getgpc("id");
     $pid = getgpc("pid");
     if ($id) {
         $res = fetch_one_array("select * from " . dbtable("employment_content") . " where id ='" . $id . "' ");
         if (!$res) {
             alert("错误,没有找到该数据", "");
         }
     }
     $content = getgpc("content");
     $istop = intval(getgpc("istop"));
     $displayorder = intval(getgpc("displayorder"));
     $status = intval(getgpc("status"));
     $indata = array('pid' => $pid, "content" => $content, "istop" => $istop, "displayorder" => $displayorder, "status" => $status);
     if (!$id) {
         //
         $indata["gtime"] = date("Y-m-d H:i:s");
         dbinsert("employment_content", $indata);
     } else {
         dbupdate("employment_content", $indata, array('id' => $id));
     }
     js_alert("保存成功", "top.location.href='?mod=employment&act=content&pid=" . $pid . "'");
 }
Exemplo n.º 10
0
 public function saveedit()
 {
     //保存产品
     $id = getgpc("id");
     if ($id) {
         $res = fetch_one_array("select * from " . dbtable("englandstyle") . " where id ='" . $id . "' ");
         if (!$res) {
             alert("错误,没有找到该数据", "");
         }
     }
     $title = getgpc("title");
     $showtime = getgpc("showtime");
     $intr = getgpc("intr");
     $content = getgpc("content");
     $simgurl = getgpc("simgurl");
     $imgurl = getgpc("imgurl");
     $lovenum = getgpc("lovenum");
     $displayorder = intval(getgpc("displayorder"));
     $status = intval(getgpc("status"));
     $indata = array("title" => $title, "showtime" => $showtime, "intr" => $intr, "content" => $content, "simgurl" => $simgurl, "imgurl" => $imgurl, "lovenum" => $lovenum, "displayorder" => $displayorder, "status" => $status);
     if (!$id) {
         //
         $indata["gtime"] = date("Y-m-d H:i:s");
         dbinsert("englandstyle", $indata);
     } else {
         $indata["uptime"] = date("Y-m-d H:i:s");
         dbupdate("englandstyle", $indata, array('id' => $id));
     }
     js_alert("保存成功", "top.location.href='?mod=englandstyle&act=index'");
 }
Exemplo n.º 11
0
 public function savecompare()
 {
     //保存门店
     $id = getgpc("id");
     if ($id) {
         $res = fetch_one_array("select * from " . dbtable("product_compare") . " where id ='" . $id . "' ");
         if (!$res) {
             alert("错误,没有找到该数据", "");
         }
     }
     $title = getgpc("title");
     $displayorder = intval(getgpc("displayorder"));
     $status = intval(getgpc("status"));
     $indata = array("title" => $title, "displayorder" => $displayorder, "status" => $status);
     if (!$id) {
         dbinsert("product_compare", $indata);
     } else {
         dbupdate("product_compare", $indata, array('id' => $id));
     }
     alert("保存成功", "admin.php?mod=product&act=compareindex");
 }
Exemplo n.º 12
0
 public function saveedit()
 {
     $id = intval(getgpc("id"));
     $tid = intval(getgpc("tid"));
     $title = getgpc("title");
     $stitle = getgpc("stitle");
     $imgurl = getgpc("imgurl");
     $intr = getgpc("intr");
     $type = getgpc("type");
     $url = getgpc("url");
     //        if(!empty($url))
     //        {
     //        	if(!strstr($url,"http://") and !strstr($url,"www") and !strstr($url,"index.php"))
     //        	{
     //				$url="index.php".$url;
     //        	}
     //        }
     //		if(!is_numeric(substr($url, -1)) and $tid=='1')
     //		{
     //			js_alert("请输入相对应产品的ID号");
     //		}
     if (empty($imgurl) and $tid != '11' and $tid != 9) {
         js_alert("上传相应的图片");
     }
     $con = getgpc("con");
     $istop = getgpc("istop");
     $displayorder = getgpc("displayorder");
     $status = getgpc("status");
     $indata = array('tid' => $tid, 'type' => $type, 'title' => $title, 'stitle' => $stitle, 'imgurl' => $imgurl, 'intr' => $intr, 'url' => $url, 'con' => $con, 'gtime' => date("Y-m-d H:i:s"), 'postip' => json_encode(convertip()), "istop" => $istop, "displayorder" => $displayorder, "status" => $status);
     if (!$id) {
         //更新
         dbinsert("indexpush", $indata);
     } else {
         //dbupdate("indexpush",$indata,"id='".$id."'");
         dbupdate("indexpush", $indata, array('id' => $id));
     }
     js_alert("保存成功", "top.location.href='?mod=indexpush&tid=" . $tid . "'");
 }