public function update() { $tag = $_GET['tag']; $Model = new \Think\Model(); $title_number = $Model->query("SELECT count(*) FROM `cloud_title`"); $article_number = $Model->query("SELECT count(*) FROM `cloud_article`"); if ($title_number[0]['count(*)'] == 0) { $this->error('请添加至少一条标题', '/index.php/Admin/TitleAdmin/index'); } if ($article_number[0]['count(*)'] < 2) { $this->error('请添加至少两个文章段落', '/index.php/Admin/ArticleAdmin/index'); } $title = $Model->query("SELECT * FROM `cloud_title`"); $article = $Model->query("SELECT * FROM `cloud_article`"); if ($article_number[0]['count(*)'] < 6) { for ($i = 0; $i < $title_number[0]['count(*)']; $i++) { $article_rand_number = array(); for ($j = 0; $j < 6; $j++) { $article_rand_number[] = rand(0, $article_number[0]['count(*)'] - 1); } $article_ids = $article[$article_rand_number[0]]['id'] . '|' . $article[$article_rand_number[1]]['id'] . '|' . $article[$article_rand_number[2]]['id'] . '|' . $article[$article_rand_number[3]]['id'] . '|' . $article[$article_rand_number[4]]['id'] . '|' . $article[$article_rand_number[5]]['id']; $result = $Model->execute("UPDATE `cloud_title` SET `article_ids`='" . $article_ids . "' WHERE `id`=" . $title[$i]['id']); if (!$result) { $this->error('更新失败', '/index.php/Admin/TitleAdmin/index'); } } } else { for ($i = 0; $i < $title_number[0]['count(*)']; $i++) { $article_rand_number = $this->unique_rand(0, $article_number[0]['count(*)'] - 1, 6); $article_ids = $article[$article_rand_number[0]]['id'] . '|' . $article[$article_rand_number[1]]['id'] . '|' . $article[$article_rand_number[2]]['id'] . '|' . $article[$article_rand_number[3]]['id'] . '|' . $article[$article_rand_number[4]]['id'] . '|' . $article[$article_rand_number[5]]['id']; $result = $Model->execute("UPDATE `cloud_title` SET `article_ids`='" . $article_ids . "' WHERE `id`=" . $title[$i]['id']); if (!$result) { $this->error('更新失败', '/index.php/Admin/TitleAdmin/index'); } } } if ($tag == 'title') { $this->success('更新成功', 'index'); } else { if ($tag == 'article') { $this->success('更新成功', '../ArticleAdmin/index'); } } }
public function delete_article() { $id = $_GET['id']; $Model = new \Think\Model(); $result = $Model->execute("DELETE FROM `cloud_article` WHERE `id`=" . $id); if ($result) { $this->success('删除成功', '/index.php/Admin/ArticleAdmin/index'); } else { $this->error('删除失败', '/index.php/Admin/ArticleAdmin/index'); } }
public function delete() { $table = I('get.table'); $sql = 'drop table ' . $table . ';'; $Model = new \Think\Model(); $result = $Model->execute($sql); if ($result === 0) { $info = $table . ' 删除成功!'; $this->assign('data', $this->data); $this->assign('success', $info); $this->redirect('index'); } }
public function delete_tpl() { $filename = $_GET['filename']; $Model = new \Think\Model(); $city = $Model->query('SELECT * FROM `cloud_city`'); for ($i = 0; $i < count($city); $i++) { if ($city[$i]['tpl_name'] == $filename) { $temp_id = $city[$i]['id']; $Model->execute("UPDATE `cloud_city` SET `tpl_name`='rand' WHERE `id`={$temp_id}"); } } $delete_dir = './Application/Home/Common/template/' . $filename; $this->deldir($delete_dir); $this->success('删除成功', '/index.php/Admin/TemplateAdmin/index'); }
public function delete_domain() { if ($_GET['id']) { $id = $_GET['id']; } else { $id = ''; } $Model = new \Think\Model(); if ($id != '') { $result = $Model->execute("DELETE FROM `cloud_domain_first` WHERE `id`=" . $id); } if ($result) { $this->success('删除成功', '/index.php/Admin/DomainFirstAdmin/index'); } else { $this->error('删除失败', '/index.php/Admin/DomainFirstAdmin/index'); } }
public function delete_external_url() { if ($_GET['id']) { $id = $_GET['id']; } else { $id = ''; } $Model = new \Think\Model(); if ($id != '') { $result = $Model->execute("DELETE FROM `cloud_external_link` WHERE `id`=" . $id); } if ($result) { $this->success('删除成功', '/index.php/Admin/ExternalLinkAdmin/index'); } else { $this->error('删除失败', '/index.php/Admin/ExternalLinkAdmin/index'); } }
/** * 系统模块管理功能,用于从商店自动部署模块、移除模块 */ public function Item() { $this->rest(["model" => "System/ModuleItem", "post" => function ($res) { $zip = "{$res["request"]["module"]}.zip"; $path = APP_PATH . $res["request"]["module"]; if (!APP_DEBUG) { /*从服务器下载模块压缩包*/ \Org\Util\Downloader::transfer(C("ENTERTILE") . C("ENTERTILE_STORE_PATH") . $zip, TEMP_PATH . $zip); /*创建模块目录*/ \Org\Util\Directory::create($path); /*解压ZIP文件*/ \Org\Util\Zip::extract(TEMP_PATH . $zip, $path); } /*加载模块配置类并初始化*/ include "{$path}/install.php"; $moduleInstaller = new \ModuleInstaller(); $config = $moduleInstaller->config; /*准备配置数据(格式化处理)*/ $rules = []; for ($i = 0, $l = count($config["menus"]); $i < $l; $i++) { $menu = $config["menus"][$i]; $menu["rules"] = []; for ($j = 0, $m = count($menu["permits"]); $j < $m; $j++) { $permit = $menu["permits"][$j]; for ($k = 0, $n = count($permit["methods"]); $k < $n; $k++) { $rule = strtolower("{$permit["methods"][$k]}{$permit["path"]}"); $rules[] = $menu["rules"][] = $rule; } } $config["menus"][$i] = $menu; } /*增加模块信息*/ $config["id"] = D("System/ModuleItem")->add(["name" => $config["name"], "title" => $config["title"], "abstract" => $config["abstract"]]); /*增加相关权限规则(如果已存在,则不添加)*/ //读取当前规则信息 $modelPermits = D("System/AuthenticationPermit")->select(); //移除已经存在的权限规则 $rules = join($rules, ";"); for ($i = 0, $l = count($modelPermits); $i < $l; $i++) { $rules = str_replace($modelPermits[$i]["name"], "", $rules); } $rules = preg_replace("/^;|;\$/", "", preg_replace("/;{2,}/", ";", $rules)); //解析新增RULE并保存到数据库 if ($rules !== "") { $rules = '[{"name":"' . str_replace(";", '"},{"name":"', $rules) . '"}]'; } D("System/AuthenticationPermit")->addAll(json_decode($rules, true)); /*将规则信息与菜单相关联*/ //读取最新规则信息 $rules = []; $modelPermits = D("System/AuthenticationPermit")->select(); for ($i = 0, $l = count($modelPermits); $i < $l; $i++) { $rules[$modelPermits[$i]["name"]] = $modelPermits[$i]["id"]; } //关联菜单权限 for ($i = 0, $l = count($config["menus"]); $i < $l; $i++) { $tPermits = []; $menu = $config["menus"][$i]; //添加菜单页面可访问权限 $menu["rules"][] = ["path" => $menu["page"], "methods" => ["GET"]]; for ($j = 0, $m = count($menu["rules"]); $j < $m; $j++) { $tPermits[] = $rules[$menu["rules"][$j]]; } //创建菜单记录 unset($config["menus"][$i]["permits"]); unset($config["menus"][$i]["rules"]); $config["menus"][$i]["title"] = $menu["menu"]; $config["menus"][$i]["module_id"] = $config["id"]; $config["menus"][$i]["rule_ids"] = join($tPermits, ","); } D("SystemModuleMenu")->addAll($config["menus"]); /*运行自定义安装脚本*/ $moduleInstaller->install(); /*返回输出*/ $res["response"] = $config; return $res; }, "delete" => function ($res) { $path = APP_PATH . $res["request"]["module"]; //执行自定义卸载脚本 include "{$path}/install.php"; $moduleInstaller = new \ModuleInstaller(); $moduleInstaller->uninstall(); /*移除模块相关文件及记录*/ $mod = new \Think\Model(); //移除对应菜单项 $mod->execute("delete from think_system_module_menu where module_id in(select id from think_system_module_item where name='%s')", [$res["request"]["module"]]); //移除模块主体 $mod->execute("delete from think_system_module_item where name='%s'", [$res["request"]["module"]]); if (!APP_DEBUG) { //移除代码 \Org\Util\Directory::unlink($path); } /*返回输出*/ return $res; }]); }
function orderhandle($parameter) { $ordid = $parameter['out_trade_no']; $data['payment_trade_no'] = $parameter['trade_no']; $data['payment_trade_status'] = $parameter['trade_status']; $data['payment_notify_id'] = $parameter['notify_id']; $data['payment_notify_time'] = $parameter['notify_time']; $data['payment_buyer_email'] = $parameter['buyer_email']; $data['ordstatus'] = 1; $tag = intval(substr($ordid, 0, 1)); $goodsnum = num; switch ($tag) { case 0: $ordlist = "orderlist"; $goodstable = "goods"; $goodsnum = "goodsnum"; break; case 1: $ordlist = "super_orderlist"; $goodstable = "super_goods"; $goodsnum = "goodsnum"; break; case 2: $ordlist = "seckill_orderlist"; $goodstable = "seckill_goods"; break; case 3: $ordlist = "teambuy_orderlist"; $goodstable = "teambuy_goods"; break; case 4: $ordlist = "trial_orderlist"; $goodstable = "trial_goods"; break; case 5: $ordlist = "book_orderlist"; $goodstable = "book_goods"; break; } // by liuyicheng // 获取账户余额 // 我只想说PHP真吊。是在下输了。完全看不懂这数据库怎么操作的。 $um = M("user_manage"); //$sql = "select balance from user_manage where user_id=".$_SESSION['id']; $balance = $um->field("balance")->where('user_id=' . $_SESSION['id'])->select()[0]['balance']; //$balance = mysql_fetch_row(mysql_query($sql)); // $parameter['total_fee']表示此次交易总金额 $total_fee = $parameter['total_fee']; // 余额不足则啥也不干直接返回 if ($total_fee > $balance) { return false; } else { // 扣除余额 $sql = "update user_manage set balance=" . ($balance - $total_fee) . " where user_id=" . $_SESSION['id']; $memeda = new \Think\Model(); $memeda->execute($sql); $Ord = M($ordlist); $model = new \Think\Model(); if ($Ord->where("merge_ordid=" . $ordid)->find()) { $Ord->where('merge_ordid=' . $ordid)->save($data); $result2 = $Ord->field("productid,shop_id,mall_id,ordbuynum,ordfee")->where('merge_ordid=' . $ordid)->select(); foreach ($result2 as $result) { //更新商品数量 $model->execute("update {$goodstable} set {$goodsnum}={$goodsnum}-" . $result["ordbuynum"] . " where id={$result['productid']}"); //更新商城钱数 $model->execute("update system_info set balanceMoney=balanceMoney+" . $result["ordfee"] . " ,useMoney=useMoney+" . $result["ordfee"]); if ($result["mall_id"] == 0) { //商城自营 } else { if ($result["shop_id"] == 0) { //商场自营 $mall = M("mall"); $mall_info = $mall->field("ratio")->where("id={$result['mall_id']}")->find(); $ordfee_temp = $result["ordfee"] * (100 - $mall_info["ratio"]) / 100; $model->execute("update mall set balanceMoney=balanceMoney+" . $ordfee_temp . " ,useMoney=useMoney+" . $ordfee_temp . " where id=" . $result["mall_id"]); } else { //商铺的 $mall = M("mall"); $mall_info = $mall->field("ratio")->where("id={$result['mall_id']}")->find(); $shop = M("shop"); $shop_info = $shop->field("ratio")->where("id={$result['shop_id']}")->find(); $ordfee_temp = $result["ordfee"] * (100 - $mall_info["ratio"]) / 100 * $shop_info["ratio"] / 100; $ordfee_temp2 = $result["ordfee"] * (100 - $shop_info["ratio"]) / 100; $model->execute("update mall set balanceMoney=balanceMoney+" . $ordfee_temp . " ,useMoney=useMoney+" . $ordfee_temp . " where id=" . $result["mall_id"]); $model->execute("update mall set balanceMoney=balanceMoney+" . $ordfee_temp2 . " ,useMoney=useMoney+" . $ordfee_temp2 . " where id=" . $result["shop_id"]); } } } } else { //不是合并付款,一个订单只有一种商品 $Ord->where('ordid=' . $ordid)->save($data); $result = $Ord->field("productid,shop_id,mall_id,ordbuynum,ordfee")->where('ordid=' . $ordid)->find(); //更新商品数量 $model->execute("update {$goodstable} set {$goodsnum}={$goodsnum}-" . $result["ordbuynum"] . " where id={$result['productid']}"); //更新商城钱数 $model->execute("update system_info set balanceMoney=balanceMoney+" . $result["ordfee"] . " ,useMoney=useMoney+" . $result["ordfee"]); if ($result["mall_id"] == 0) { //商城自营 } else { if ($result["shop_id"] == 0) { //商场自营 $mall = M("mall"); $mall_info = $mall->field("ratio")->where("id={$result['mall_id']}")->find(); $ordfee_temp = $result["ordfee"] * (100 - $mall_info["ratio"]) / 100; $model->execute("update mall set balanceMoney=balanceMoney+" . $ordfee_temp . " ,useMoney=useMoney+" . $ordfee_temp . " where id=" . $result["mall_id"]); } else { //商铺的 $mall = M("mall"); $mall_info = $mall->field("ratio")->where("id={$result['mall_id']}")->find(); $shop = M("shop"); $shop_info = $shop->field("ratio")->where("id={$result['shop_id']}")->find(); $ordfee_temp = $result["ordfee"] * (100 - $mall_info["ratio"]) / 100 * $shop_info["ratio"] / 100; $ordfee_temp2 = $result["ordfee"] * (100 - $shop_info["ratio"]) / 100; $model->execute("update mall set balanceMoney=balanceMoney+" . $ordfee_temp . ", useMoney=useMoney+" . $ordfee_temp . " where id=" . $result["mall_id"]); $model->execute("update shop set balanceMoney=balanceMoney+" . $ordfee_temp2 . " ,useMoney=useMoney+" . $ordfee_temp2 . " where id=" . $result["shop_id"]); } } } return true; } }
public function del() { if (!IS_AJAX) { $this->error(L('_ERROR_ACTION_')); } $Field = D('Field'); $delitem = $Field->where('id=' . I('get.id'))->find(); $module = M('Module')->getFieldById($delitem['mid'], 'name'); $fields = M($module)->getDbFields(); if (in_array($delitem['field'], $fields)) { $style = $thumb = ''; if ($delitem['type'] == 'title') { $style = in_array($delitem['field'] . '_style', $fields) ? ', DROP `' . $delitem['field'] . '_style`' : ''; $thumb = in_array('thumb', $fields) ? ', DROP `thumb`' : ''; } $sql = 'ALTER TABLE `' . C('DB_PREFIX') . strtolower($module) . '` DROP `' . $delitem['field'] . '`' . $style . $thumb . ';'; $model = new \Think\Model(); $res = $model->execute($sql); if ($res === FALSE) { $this->error(L('DEL_ERROR')); } } $Field->where('id=' . $delitem['id'])->delete(); $this->success(L('DEL_OK'), U('Field/index', $this->vl . '&type=' . I('get.type') . '&mid=' . I('get.mid'))); }
function saveAllSql($store_db_name, $matrix, $field = 0, $db_prefix = '') { // if (!checkIfMatrix($matrix)) {//data_array应该是一个二维数组 // E('input的不是matrix类型'); // } if (!checkIfMatrix($matrix)) { echo 'fail inserting at ', time(), '<br/>'; return false; } /*按照field过滤下matrix-->data_matrix*/ if ($field !== 0) { $data_matrix = array(); foreach ($matrix as $key => $data_array) { foreach ($data_array as $key_lv2 => $value) { if (in_array($key_lv2, $field)) { $data_matrix[$key][$key_lv2] = $value; } } } } else { $data_matrix = $matrix; } foreach ($data_matrix as $key => $data_array) { foreach ($data_array as $key_lv2 => $value) { $data_array_tmp[$key_lv2] = "'" . $value . "'"; } $insert_data_string_row[] = '(' . implode(',', $data_array_tmp) . ')'; } $insert_data_string = implode(',', $insert_data_string_row); $col_array = array_keys($data_matrix[0]); foreach ($col_array as $key => $value) { $col_array[$key] = '`' . $value . '`'; //加上`符号 } $col_string = implode(',', $col_array); $sql_comm = "replace into `" . $db_prefix . $store_db_name . "` (" . $col_string . ") VALUES" . $insert_data_string; // $sql_comm="insert into `".$db_prefix.$store_db_name."` (".$col_string.") VALUES".$insert_data_string." on duplicate key update"; $Model = new \Think\Model(); // print_r($sql_comm); return $Model->execute($sql_comm); }
public function changesex() { $Model = new \Think\Model(); $Model->execute("update tbl_image set sex='女' where uid in (2016211117, 2016211237, 2016212856, 2016213646, 2016210813, 2016213368, 2016210002, 2016213425, 2016210076, 2016212169, 2016213495, 2016213299, 2016213547, 2016212132, 2016213310, 2016213737, 2016214425,2016210006, 2016213590, 2016212428, 2016211172, 2016211442, 2016211140, 2016211407, 2016211435, 2016211032, 2016214597)"); }
public function del() { if (!IS_AJAX) { $this->error(L('_ERROR_ACTION_')); } $id = I('get.id'); $Module = D('Module'); $modata = $Module->where('id=' . $id)->find(); $delmo = $Module->where('id=' . $id)->delete(); if ($delmo === FALSE) { $this->error(L('DEL_ERROR')); } $tablename = C('DB_PREFIX') . $modata['name']; $db = new \Think\Model(); $db->execute('DROP TABLE IF EXISTS `' . $tablename . '`;'); M('Menu')->where('model=\'' . ucfirst($modata['name']) . '\'')->delete(); M('Field')->where('mid=' . $modata['id'])->delete(); M('Content')->where('mid=' . $modata['id'])->delete(); $map['name'] = array('like', ucfirst($modata['name']) . '/' . '%'); M('AuthRule')->where($map)->delete(); $modules = F('modules'); $res = array_unique($modules); $key = array_search(ucfirst($modata['name']), $res); if ($key !== FALSE) { unset($res[$key]); } F('modules', $res); $this->success(L('DEL_OK'), U('Module/index', 'type=' . $modata['type'] . '&' . $this->vl)); }
public function change_tpl_name() { $id = $_POST['id']; $value = $_POST['value']; $Model = new \Think\Model(); $result = $Model->execute("UPDATE `cloud_city` SET `tpl_name`='{$value}' WHERE `id`={$id}"); if ($result) { echo '修改成功'; } else { echo '修改失败'; } }
function orderhandle($parameter) { $ordid = $parameter['out_trade_no']; $data['payment_trade_no'] = $parameter['trade_no']; $data['payment_trade_status'] = $parameter['trade_status']; $data['payment_notify_id'] = $parameter['notify_id']; $data['payment_notify_time'] = $parameter['notify_time']; $data['payment_buyer_email'] = $parameter['buyer_email']; $data['ordstatus'] = 1; $tag = intval(substr($ordid, 0, 1)); $goodsnum = num; switch ($tag) { case 0: $ordlist = "orderlist"; $goodstable = "goods"; $goodsnum = "goodsnum"; break; case 1: $ordlist = "super_orderlist"; $goodstable = "super_goods"; $goodsnum = "goodsnum"; break; case 2: $ordlist = "seckill_orderlist"; $goodstable = "seckill_goods"; break; case 3: $ordlist = "teambuy_orderlist"; $goodstable = "teambuy_goods"; break; case 4: $ordlist = "trial_orderlist"; $goodstable = "trial_goods"; break; case 5: $ordlist = "book_orderlist"; $goodstable = "book_goods"; break; } $Ord = M($ordlist); $model = new \Think\Model(); if ($Ord->where("merge_ordid=" . $ordid)->find()) { $Ord->where('merge_ordid=' . $ordid)->save($data); $result2 = $Ord->field("productid,shop_id,mall_id,ordbuynum,ordfee")->where('merge_ordid=' . $ordid)->select(); foreach ($result2 as $result) { //更新商品数量 $model->execute("update {$goodstable} set {$goodsnum}={$goodsnum}-" . $result["ordbuynum"] . " where id={$result['productid']}"); //更新商城钱数 $model->execute("update system_info set balanceMoney=balanceMoney+" . $result["ordfee"] . " ,useMoney=useMoney+" . $result["ordfee"]); if ($result["mall_id"] == 0) { //商城自营 } else { if ($result["shop_id"] == 0) { //商场自营 $mall = M("mall"); $mall_info = $mall->field("ratio")->where("id={$result['mall_id']}")->find(); $ordfee_temp = $result["ordfee"] * (100 - $mall_info["ratio"]) / 100; $model->execute("update mall set balanceMoney=balanceMoney+" . $ordfee_temp . " ,useMoney=useMoney+" . $ordfee_temp . " where id=" . $result["mall_id"]); } else { //商铺的 $mall = M("mall"); $mall_info = $mall->field("ratio")->where("id={$result['mall_id']}")->find(); $shop = M("shop"); $shop_info = $shop->field("ratio")->where("id={$result['shop_id']}")->find(); $ordfee_temp = $result["ordfee"] * (100 - $mall_info["ratio"]) / 100 * $shop_info["ratio"] / 100; $ordfee_temp2 = $result["ordfee"] * (100 - $shop_info["ratio"]) / 100; $model->execute("update mall set balanceMoney=balanceMoney+" . $ordfee_temp . " ,useMoney=useMoney+" . $ordfee_temp . " where id=" . $result["mall_id"]); $model->execute("update mall set balanceMoney=balanceMoney+" . $ordfee_temp2 . " ,useMoney=useMoney+" . $ordfee_temp2 . " where id=" . $result["shop_id"]); } } } } else { //不是合并付款,一个订单只有一种商品 $Ord->where('ordid=' . $ordid)->save($data); $result = $Ord->field("productid,shop_id,mall_id,ordbuynum,ordfee")->where('ordid=' . $ordid)->find(); //更新商品数量 $model->execute("update {$goodstable} set {$goodsnum}={$goodsnum}-" . $result["ordbuynum"] . " where id={$result['productid']}"); //更新商城钱数 $model->execute("update system_info set balanceMoney=balanceMoney+" . $result["ordfee"] . " ,useMoney=useMoney+" . $result["ordfee"]); if ($result["mall_id"] == 0) { //商城自营 } else { if ($result["shop_id"] == 0) { //商场自营 $mall = M("mall"); $mall_info = $mall->field("ratio")->where("id={$result['mall_id']}")->find(); $ordfee_temp = $result["ordfee"] * (100 - $mall_info["ratio"]) / 100; $model->execute("update mall set balanceMoney=balanceMoney+" . $ordfee_temp . " ,useMoney=useMoney+" . $ordfee_temp . " where id=" . $result["mall_id"]); } else { //商铺的 $mall = M("mall"); $mall_info = $mall->field("ratio")->where("id={$result['mall_id']}")->find(); $shop = M("shop"); $shop_info = $shop->field("ratio")->where("id={$result['shop_id']}")->find(); $ordfee_temp = $result["ordfee"] * (100 - $mall_info["ratio"]) / 100 * $shop_info["ratio"] / 100; $ordfee_temp2 = $result["ordfee"] * (100 - $shop_info["ratio"]) / 100; $model->execute("update mall set balanceMoney=balanceMoney+" . $ordfee_temp . ", useMoney=useMoney+" . $ordfee_temp . " where id=" . $result["mall_id"]); $model->execute("update shop set balanceMoney=balanceMoney+" . $ordfee_temp2 . " ,useMoney=useMoney+" . $ordfee_temp2 . " where id=" . $result["shop_id"]); } } } }