Beispiel #1
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'");
 }
Beispiel #2
0
function entry_onsubmit($param, $post)
{
    $data = ["msglist" => gettable("select * from site_guestbook")];
    $scr = new Scriptor("site_guestbook/guestbook.html", $data);
    if (($post = $scr->validate("entry", $post)) === false) {
        return $scr->result();
    }
    dbinsert("site_guestbook", ["name" => $post["name"], "content" => $post["content"]]);
    return child_render($param);
}
Beispiel #3
0
function subscribe_onsubmit($param, $post)
{
    global $_SERVER;
    $scr = new Scriptor("site_guestbook/purchase.html");
    if (($post = $scr->validate("emailsubscribe", $post)) === false) {
        return $scr->result();
    }
    dbinsert("beta_emails", ["email" => $post["email"], "landing" => $_SERVER["SERVER_NAME"]]);
    return redirect("/thanks");
}
Beispiel #4
0
 /**
  * Called when migrating up
  */
 public function up()
 {
     //fetch duplicate rows
     $duplicate_rows = dbfetch("SELECT *, COUNT(*) AS count FROM `#__edges` GROUP BY `type`, `node_a_id`, `node_a_type`, `node_b_id`, `node_b_type` HAVING count > 1");
     //delete duplicate rows
     foreach ($duplicate_rows as $row) {
         dbexec('DELETE FROM `#__edges` WHERE `type`=\'' . $row['type'] . '\' AND `node_a_id`=\'' . $row['node_a_id'] . '\' AND `node_a_type`=\'' . $row['node_a_type'] . '\' AND `node_b_id`=\'' . $row['node_b_id'] . '\' AND `node_b_type`=\'' . $row['node_b_type'] . '\' ');
     }
     //add unique constraint to columns
     dbexec('ALTER TABLE `#__edges` ADD CONSTRAINT `uc_edge` UNIQUE(`type`, `node_a_id`, `node_a_type`, `node_b_id`, `node_b_type`)');
     //insert previously duplicate rows once each
     foreach ($duplicate_rows as $row) {
         unset($row['id']);
         unset($row['count']);
         dbinsert('edges', $row);
     }
 }
Beispiel #5
0
if (isset($_SERVER["argv"]) && isset($_SERVER["SCRIPT_FILENAME"]) && basename($_SERVER["SCRIPT_FILENAME"]) == basename(__FILE__)) {
    echo "cog_database: Running self-tests...\n";
    // set up asserts
    assert_options(ASSERT_ACTIVE, 1);
    assert_options(ASSERT_WARNING, 0);
    assert_options(ASSERT_QUIET_EVAL, 0);
    // Set up the callback
    assert_options(ASSERT_CALLBACK, function ($file, $line, $code) {
        echo "Assertion Failed:\n File '{$file}' \n  Line '{$line}'  Code '{$code}'\n\n";
    });
    assert(initsql());
    assert(resolvequery("VALUES (@email, @example)", array("email" => "*****@*****.**", "example" => 123)) == 'VALUES ("*****@*****.**", "123")');
    // table-based testing
    dbcommit("drop table if exists cog_testing");
    dbcommit("create table if not exists cog_testing (id int primary key auto_increment, username varchar(64), status enum('live', 'deleted') default 'live', created datetime )");
    dbinsert("cog_testing", ["username" => random_string(16)], ["created" => "now()"]);
    $q = gettable("select * from cog_testing where status = 'live' ");
    assert(count($q) == 1);
    // unique insert testing
    $res = dbuniqueinsert("cog_testing", ["username" => "unique"], ["username" => "unique", "status" => "live"], ["created" => "now()"]);
    assert($res !== false);
    // this should return with new ID
    $q = gettable("select * from cog_testing where status = 'live' ");
    assert(count($q) == 2);
    $res = dbuniqueinsert("cog_testing", ["username" => "unique"], ["username" => "unique", "status" => "live"], ["created" => "now()"]);
    assert($res == 0);
    // this should return 0
    dbcommit("drop table if exists cog_testing");
    // clean up
    echo "Self-tests finished\n";
}
Beispiel #6
0
	<div style="clear: both;"></div>
	<div class="container">
<?php 
require 'functions.php';
if (isset($_POST['import'])) {
    $import = $_POST['import'];
    $arr = explode(',', $import);
    $run = srvimport($arr['0'], $arr['1'], $arr['2'], $arr['3'], $arr['4'], $arr['5'], $arr['6'], $arr['7'], $arr['8'], $arr['9'], $arr['10'], $arr['11'], $arr['12'], $arr['13']);
    if ($run == true) {
        echo "<div class=\"view-messages\">Import Successful!</div>";
    } else {
        echo "<div class=\"view-messages\">Import Failed.</div>";
    }
}
if (isset($_POST['name'])) {
    $run = dbinsert($_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']);
    if ($run == true) {
        echo "<div class=\"view-messages\">Creation Successful!</div>";
    } else {
        echo "<div class=\"view-messages\">Creation Failed. Please make sure all fields are filled out.</div>";
    }
}
if (isset($_POST['delsid']) and is_numeric($_POST['delsid'])) {
    $delete = dbdel($_POST['delsid']);
    if ($delete == true) {
        echo "<div class=\"view-messages\">Success!</div>";
    } else {
        echo "<div class=\"view-messages\">Failed.</div>";
    }
}
?>
function set_product($upc, $sid, $description, $brand, $upc, $sku, $wholesale_price, $retail_price)
{
    global $link;
    $pid = get_product_id($upc, $sid);
    if (empty($pid)) {
        $data = array('created_at' => '2014-11-11 11:11:11', 'is_archived' => 0, 'is_processed' => 0, 'is_tracked' => 1, 'is_violated' => 0, 'price_floor' => 0, 'retail_price' => $retail_price, 'sku' => $sku, 'status' => 1, 'store_id' => $sid, 'title' => $description, 'upc_code' => $upc, 'wholesale_price' => $wholesale_price);
        $pid = dbinsert($link, 'products', $data);
        if (!$pid) {
            var_dump($pid);
            exit;
        }
    }
    return $pid;
}
Beispiel #8
0
function log_start()
{
    global $g_log_id;
    $g_log_id = dbinsert("sys_logs", ["ip" => $_SERVER["REMOTE_ADDR"], "agent" => isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : "", "referer" => isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "", "url" => $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"], "permsid" => session_id()]);
    return true;
}
Beispiel #9
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'");
 }
Beispiel #10
0
 function savelink()
 {
     //新建
     $lid = intval(getgpc("id"));
     $link_value = getgpc("link_value");
     if ($link_value == 1) {
         $insdata = array("lid" => $lid, "gtime" => date("Y-m-d H:i:s"));
         dbinsert('newslink', $insdata);
         alert("推荐新闻成功", "");
     } else {
         $ch = $this->db->query("delete from " . dbtable("newslink") . " where lid='" . $lid . "'");
         if ($ch) {
             alert("取消推荐成功", "");
         } else {
             alert("取消推荐失败", "");
         }
     }
     //面包屑导航
 }
Beispiel #11
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'");
 }
Beispiel #12
0
 function faq_save()
 {
     $name = getgpc("name");
     $tel = getgpc("tel");
     $email = getgpc("email");
     $question = getgpc("question");
     if (empty($name)) {
         js_alert("请输入姓名");
     }
     if (empty($tel)) {
         js_alert("请输入联系电话");
     }
     if (empty($email)) {
         js_alert("请输入Email");
     }
     if (empty($question)) {
         js_alert("请输入问题描述");
     }
     $indata = array("name" => $name, "tel" => $tel, "email" => $email, "question" => $question, "reply_sign" => 1, "displayorder" => 0, "status" => 1);
     $indata["gtime"] = date("Y-m-d H:i:s");
     dbinsert("faq", $indata);
     js_alert("提交成功", "top.location.href='?c=home&m=faq'");
 }
Beispiel #13
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 . "'");
 }
Beispiel #14
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");
 }
Beispiel #15
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 . "'");
 }