<?php session_start(); // error_reporting(null); if (!isset($_SESSION['uid'])) { header("Location: login.php"); exit; } date_default_timezone_set('Asia/Shanghai'); include "./medoo.min.php"; $database = new medoo(); if (isset($_GET['qid']) && isset($_POST['reply'])) { $name = $database->select("user", "name", array("id" => $_SESSION['uid'])); $database->insert("answer", array("qid" => $_GET['qid'], "name" => $name[0], "content" => $_POST['reply'])); $database->update("question", array("isanswer" => 1), array("id" => $_GET['qid'])); header("Location: my.php"); }
/** * 导入数据到 wd_120answer_temp 中 * @author gaoqing * 2015年11月9日 * @param array $initAskArr 初始要导入的问答信息集 * @param int $preInsertCount 每次插入的条数 * @param medoo $connection 连接数据库对象 * @param int $sleepSeconds 休眠的秒数 * @return int $importCount 成功导入的信息数 */ function importData($initAskArr, $preInsertCount, $connection, $sleepSeconds) { $importCount = 0; $data = array("isimport" => 1); $insertArr = array(); $updateIDArr = array(); $initAskArrCount = count($initAskArr); foreach ($initAskArr as $key => $initAsk) { if ($key % 100 == 0) { sleep($sleepSeconds); } $insertArr[] = getInserArr($initAsk); $updateIDArr[] = $initAsk['id']; if ($key % $preInsertCount == $preInsertCount - 1 || $key == $initAskArrCount - 1) { //将 $insertArr 数组集,插入到 wd_fhanswer_temp 中 if (!empty($insertArr)) { //插入到 wd_120answer_temp 中 $idArr = $connection->insert(IMPORT_TABLE, $insertArr); $importCount += count($insertArr); $insertArr = array(); //更新 wd_120answer_keshi 中的信息 $where = array('id' => $updateIDArr); $connection->update(SELECT_TABLE, $data, $where); $updateIDArr = array(); } } } return $importCount; }
/** * Add new record to to DB * @param array $args * @param bool $extCall * @return int|string id of new record * @throws FatalError * @throws \Exception */ public function saveNew($args, $extCall = false) { $this->gp->checkAccess(__FUNCTION__, $extCall); $parsed_arg = $this->checkArguments($args); $parsed_arg = $this->parseJson($parsed_arg, true); if (EMA_DEBUG && EMA_LOG_SQL_QUERIES) { $this->logInsertQuery($this->dbTable, $parsed_arg); } $dbData = $this->dbConnection->insert($this->dbTable, $parsed_arg); if (is_numeric($dbData) === true and $dbData > 0) { if ($this->isImplement("FileManage") && !empty($_FILES)) { $uploadedData = $this->saveUploadedFile($dbData); $parsed_arg = $this->parseJson($parsed_arg); /** @var array $parsed_arg */ $parsed_arg['id'] = $dbData; $parsed_arg = array_replace_recursive($parsed_arg, $uploadedData); $this->save($parsed_arg); } if ($this->isImplement("Sitemap")) { $this->generateSitemap(); } if ($this->isImplement("RssFeed")) { $this->rssFeedUpdate(); } return $dbData; } else { $this->throwMysqlError(); } }
/** * @param string $table * @param array $datas * @return bool|int */ public function insert($table, $datas) { $n = 0; if (isset($datas[0])) { foreach ($datas as $data) { parent::insert($table, $data); $this->lastSql = $this->last_query(); $this->lastError = $this->error(); if ($this->lastError[0] == '00000') { $n += 1; } } } else { parent::insert($table, $datas); $this->lastSql = $this->last_query(); $this->lastError = $this->error(); if ($this->lastError[0] == '00000') { $n = 1; } } return $n; }
ini_set('display_errors', 'ON'); error_reporting(E_ALL); header("Content-type:text/html;charset=utf-8"); defined('ROOT_PATH') or define('ROOT_PATH', dirname(__FILE__)); include ROOT_PATH . '/../lib/medoo.php'; include ROOT_PATH . '/../lib/Curl.php'; $db = new medoo(array('database_type' => 'mysql', 'database_name' => 'fayuan', 'server' => 'localhost', 'username' => 'root', 'password' => '123456', 'port' => 3306, 'charset' => 'utf8', 'option' => array(PDO::ATTR_CASE => PDO::CASE_NATURAL))); $curl = new Curl(); $id = 2250; while ($id <= 1239000) { $url = "http://shixin.court.gov.cn/detail?id={$id}"; $resArr = getHtml($url); echo "{$id}\r\n"; if (is_array($resArr) && !empty($resArr)) { //判断数据是否存在 print_r($resArr); $i = $db->insert('shixin', $resArr); if ($i <= 0) { print_r($db->error()); die; } } $id++; } function getHtml($url) { global $curl; $curl->setUrl($url); $html = $curl->run(); return json_decode($html, true); }
<?php session_start(); error_reporting(null); date_default_timezone_set('Asia/Shanghai'); include "./medoo.min.php"; $database = new medoo(); if (isset($_POST['uid']) && isset($_POST['qid'])) { $database->insert("who", array("qid" => $_POST['qid'], "uid" => $_POST['uid'])); $database->update("question", array("isreply" => 1), array("id" => $_POST['qid'])); header("Location: manager.php"); }
if ($method == "login") { $pw = sha1($_POST['password']); $uname = $_POST['user_name']; $data = $database->select("users", ["password", "user_name", "user_id"], ["user_name" => $uname]); if ($data[0]['password'] == $pw) { $data[0]['password'] = ""; print json_encode($data); $_SESSION['user_id'] = $data[0]['user_id']; } else { print json_encode([]); } } else { if ($method == "create") { $pw = sha1($_POST['password']); $uname = $_POST['user_name']; $data = $database->insert("users", ["user_name" => $uname, "password" => $pw]); $resp = ["user_name" => $uname, "user_id" => $data]; print json_encode($resp); } else { if ($method == "game_list") { $data = $database->select("game", "*", []); print json_encode($data); } else { if ($method == "game_view") { $game_id = $_GET['game_id']; $result = getGameData($database, $game_id, $user_id); print json_encode($result); } else { if ($method == "create_game") { $game_name = $_POST['game_name']; $data = ["game_name" => $game_name, "game_type" => "sh", "game_status" => "pending", "owner_id" => $user_id];
if (count($is_phone_exists) == 0) { if (isset($_FILES['image'])) { $errors = array(); $file_name = $_FILES['image']['name']; $file_size = $_FILES['image']['size']; $file_tmp = $_FILES['image']['tmp_name']; $file_type = $_FILES['image']['type']; $file_ext = strtolower(end(explode('.', $_FILES['image']['name']))); $expensions = array("jpeg", "jpg", "png"); if (in_array($file_ext, $expensions) === false) { $errors[] = "extension not allowed, please choose a JPEG or PNG file."; } if ($file_size > 2097152) { $errors[] = 'File size must be excately 2 MB'; } if (empty($errors) == true) { move_uploaded_file($file_tmp, "profile_pic/" . $phone . $file_ext); $image_path = "profile_pic/" . $phone . $file_ext; echo "Success"; } else { print_r($errors); } } $database->insert("krishok", ["full_name" => $fullname, "district" => $district, "address" => $address, "phone" => $phone, "password" => $pass, "profile_pic_path" => $image_path]); } else { echo 'Already Registered'; } } else { echo 'Something wrong'; } }
$app->notfound(); } }); $app->get("/secindex", function () use($app) { try { $app->render("secindex.html"); } catch (Exception $e) { $app->notfound(); } }); $app->get("/thirdindex/:uid/:type", function ($uid, $type) use($app, $databases) { try { $ftype = $app->getCookie("ctype"); $stype = $app->getCookie("csectype"); $ttype = $app->getCookie("csort"); $f = $databases->insert("history", array("uuid" => $uid, "ftype" => $ftype, "stype" => $stype, "ttype" => $ttype)); if ($type > 2) { $datas = $databases->select("user", "expire", array("uuid" => $uid, "ORDER" => array("id DESC", "time DESC"))); if (count($datas) > 0) { $now = time(); if ($now > $datas[0]) { $app->redirect("../../buy"); } else { $app->render("thirdindex.html"); } } else { $app->redirect("../../buy"); } } else { $app->render("thirdindex.html"); }
<?php require_once 'meedoo.php'; require_once 'config.php'; $database = new medoo(); $mealID = $_POST["mealID"]; $name = $_POST["name"]; $type = $_POST["type"]; $ingredients = $_POST["ingredients"]; $instructions = $_POST["instructions"]; $user = $_POST["user"]; // LATER --> double check if meal exists first echo 'MEALID:::: ' . $mealID; //if not... $add = $database->insert('meals', ['mealID' => $mealID, 'name' => $name, 'status' => 'active', 'type' => $type, 'ingredients' => $ingredients, 'instructions' => $instructions, 'user' => $user]); if ($add) { echo 'good'; } else { echo 'bad'; }
* 连接数据库 */ echo "_______________\n"; $database = new medoo('meetingmanage'); print_r($database->info()); /* * 查看错误信息 */ echo "_______________\n"; $database->select("bccount", array("user_name", "email"), array("user_id[<]" => 20)); var_dump($database->error()); /* * 查看上一条query */ echo "_______________\n"; $last_user_id = $database->insert("test", array("user" => "fooa", "email" => "*****@*****.**", "id" => 25, "pwd" => "smart", "name" => array("en", "fr", "jp", "cn"))); echo $database->last_query(); /* * quote函数,单引号 */ echo "_______________\n"; $data = "Medoo"; echo "we love" . $data . "\n"; echo "we love" . $database->quote($data); /* * query()函数 */ echo "_______________\n"; $data1 = $database->query("select * from test")->fetchAll(); print_r($data1); /*
<?php session_start(); error_reporting(null); date_default_timezone_set('Asia/Shanghai'); include "./medoo.min.php"; $database = new medoo(); if (isset($_POST['title'])) { $database->insert("question", array("name" => $_POST['user'], "title" => $_POST['title'], "content" => $_POST['des'], "call" => $_POST['call'], "isreply" => 0, "isanswer" => 0)); $result = array(); $result['status'] = "success"; echo json_encode($result); } else { $result = array(); $result['status'] = "wrong"; echo json_encode($result); }
$datas = $database->select("xp_posts", ["[>]wp_posts" => ["post_name" => "post_name"]], ["xp_posts.id(id)", "xp_posts.post_title(post_title)", "xp_posts.post_name(post_name)", "wp_posts.id(idn)", "wp_posts.post_title(post_titlen)", "wp_posts.post_name(post_namen)"], ["AND" => ["xp_posts.post_status" => 'publish', "xp_posts.post_parent" => '0', "xp_posts.post_type" => 'post']]); foreach ($datas as $data) { //echo "ID:" . $data["id"] . "IDnew:".$data["idn"]." - <br/>"; $i++; if (!empty($data["idn"])) { // Search in xp_postmeta record with ID of Featured image $metas = $database->select("xp_postmeta", ["post_id", "meta_key", "meta_value"], ["AND" => ["post_id" => $data["id"], "meta_key" => "_thumbnail_id"]]); //echo $metas['0']["post_id"]."---".$data["idn"]."---".$metas['0']["meta_value"]."<br>"; // Posts can be without featured image, so we make check if (!empty($metas['0']["meta_value"])) { // Select from old table all Featured Images information $images = $database->select("xp_posts", ["id", "post_title", "post_name", "post_mime_type", "guid"], ["AND" => ["post_status" => 'inherit', "post_parent" => $data["id"], "post_type" => 'attachment', "id" => $metas['0']['meta_value']]], ["ORDER" => "xp_posts.id DESC", "LIMIT" => 1]); foreach ($images as $img) { //echo "ID:" . $img["id"] . "IDnew:".$img["guid"]." - <br/>"; // Insert record with Images information to wp_post $last_user_id = $database->insert("wp_posts", ["post_author" => "1", "post_date" => "2015-12-15 11:13:52", "post_date_gmt" => "2015-12-15 08:13:52", "post_title" => $img["post_title"], "post_status" => "inherit", "comment_status" => "open", "ping_status" => "open", "post_name" => $img["post_name"], "post_modified" => "2016-01-25 01:03:55", "post_modified_gmt" => "2016-01-25 01:03:55", "post_parent" => $data["idn"], "guid" => $img["guid"], "menu_order" => "0", "post_type" => "attachment", "post_mime_type" => $img["post_mime_type"], "comment_count" => "0"]); ////// select meta information from xp_postmeta $meta_all = $database->select("xp_postmeta", ["post_id", "meta_key", "meta_value"], ["post_id" => $metas['0']['meta_value']]); ////// ###select from wp_postmeta ///// foreach ($meta_all as $meta) { //echo "ID:" . $meta["post_id"] . "IDnew:".$meta["meta_value"]." - <br/>"; // Insert meta information to wp_postmeta $last_id = $database->insert("wp_postmeta", ["post_id" => $last_user_id, "meta_key" => $meta["meta_key"], "meta_value" => $meta["meta_value"]]); } // Insert meta information to wp_postmeta $last_id = $database->insert("wp_postmeta", ["post_id" => $data["idn"], "meta_key" => "_thumbnail_id", "meta_value" => $last_user_id]); } // Delete incorect records from wp_postmeta $meta_del = $database->select("wp_postmeta", ["meta_id"], ["AND" => ["post_id" => $data["idn"], "meta_key" => "_thumbnail_id", "meta_value" => $metas['0']['meta_value']]]); if (!empty($meta_del['0']['meta_id'])) { $database->delete("wp_postmeta", ["meta_id" => $meta_del['0']['meta_id']]);
<?php require_once 'medoo.php'; //configuro database $database = new medoo(['database_type' => 'mysql', 'database_name' => 'test', 'server' => 'localhost', 'username' => 'root', 'charset' => 'utf8']); //qui processerò i parametri provenienti da ajax $comunePartenzaSelezionato = $_POST['comunePartenza']; $comuneArrivoSelezionato = $_POST['comuneArrivo']; $giornoPartenza = $_POST['giorno']; $spazioDisponibileSelezionato = $_POST['spazio']; $nomeAnnuncioViaggio = $_POST['nomeViaggio']; $mailAnnuncioViaggio = $_POST['mailViaggio']; $phoneAnnuncioViaggio = $_POST['phoneViaggio']; //qui inserirò i dati nel db $database->insert('viaggi', ['ksCodIstatComunePartenza' => $comunePartenzaSelezionato, 'ksCodIstatComuneArrivo' => $comuneArrivoSelezionato, 'giornoPartenza' => $giornoPartenza, 'spazioDisponibile' => $spazioDisponibileSelezionato, 'nome' => $nomeAnnuncioViaggio, 'mail' => $mailAnnuncioViaggio, 'phone' => $phoneAnnuncioViaggio]);
if (file_exists("assert/docs/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { $name = $_FILES['file']['name']; $path = "./assert/docs/" . $_FILES["file"]["name"]; move_uploaded_file($_FILES["file"]["tmp_name"], "assert/docs/" . $_FILES["file"]["name"]); } } //} //else{ // echo "文件不合法!"; //} $type = $_POST['type']; $db = new medoo('meetingmanage'); $did = $db->max('docspace', 'DOC_ID'); $did += 1; $db->insert('docspace', array('DOC_ID' => $did, 'MEETING_ID' => $mid, 'TYPE' => $type, 'DATE' => date("Y/m/d"), 'PATH' => $path, 'NAME' => $name)); ?> <html> <head> </head> <body style="background:#ffffff"> <script type="text/javascript"> alert('文件上传成功!') </script> <meta http-equiv="refresh" content="100;url='./mymeeting.php'"/> </body> </html>
<?php // phpinfo(); require 'vendor/autoload.php'; $db = new medoo(['database_type' => 'mysql', 'database_name' => 'test', 'server' => 'localhost', 'username' => 'root', 'password' => '', 'option' => [PDO::ATTR_CASE => PDO::CASE_NATURAL]]); $r = $db->insert("user", []); var_dump($r); var_dump($db->log()); var_dump($db->error());
/** * Created by PhpStorm. * User: KeenSting * Date: 2015/7/8 * Time: 12:30 */ include './parameter/Medoo/Resource/medoo.php'; $num = $_POST['num']; $space = $_POST['space']; $ppt = $_POST['ppt']; $mic = $_POST['mic']; $board = $_POST['board']; $mydb = new medoo('meetingmanage'); $id = $mydb->max('rooms', 'ROOM_ID'); $mydb->insert('rooms', array('ROOM_ID' => $id + 1, 'NUM' => $num, 'SPACE' => $space, 'ONE1' => 0, 'ONE2' => 0, 'ONE3' => 0, 'ONE4' => 0, 'ONE5' => 0, 'ONE6' => 0, 'TWO1' => 0, 'TWO2' => 0, 'TWO3' => 0, 'TWO4' => 0, 'TWO5' => 0, 'TWO6' => 0, 'THREE1' => 0, 'THREE2' => 0, 'THREE3' => 0, 'THREE4' => 0, 'THREE5' => 0, 'THREE6' => 0, 'MIC' => $mic, 'PPT' => $ppt, 'BOARD' => $board, 'STATE' => 1)); ?> <html> <head> </head> <body style="background-color: #ffffff;"> <script> alert('新的会议室已添加!'); </script> </body> <meta http-equiv="refresh" content="1;url='./meetingroom.php'"> </html>
//redo array to have key/value for this foreach ($questdb as &$quest) { $questions[$quest['qid']] = $quest['text']; } //match the arrays up and post the data foreach ($_POST['choice'] as &$choice) { $choice = (int) $choice; if (!empty($questions[$choice])) { $choicedb[] = $choice; } else { die('<img src="http://i.imgur.com/cuMtVS8.jpg"><br><br><h1>Missing Choice<br>WTF DID YOU DO? STOP F*****G ABOUT WITH THE POST DATA</h1>'); } } //store votes foreach ($choicedb as &$cid) { $id = $database->insert("votes", ["ip" => $ip, "qid" => $cid, "pid" => $pid, "data" => 1]); //update results $id2 = $database->update("results", ["amount[+]" => 1], ["AND" => ["qid" => $cid, "pid" => $pid]]); } break; case 2: //Single Choice $questdb = $database->select("questions", ["qid", "text"], ["pid" => $pid]); //redo array to have key/value for this foreach ($questdb as &$quest) { $questions[$quest['qid']] = $quest['text']; } //match the arrays up and post the data $choice = (int) $_POST['radio']; if (!empty($questions[$choice])) { $id = $database->insert("votes", ["ip" => $ip, "qid" => $choice, "pid" => $pid, "data" => 1]);
echo '<h1 style="color: red">信息填充不完整!</h1><meta http-equiv="refresh" content="2;url=http://ambassador.erhuoapp.com/' . $type . '/project/htdocs/adduser.php">'; exit; } try { if ($_POST['auth'] == 0) { $level = 21; } elseif ($_POST['auth'] == 1) { $level = 11; } else { $level = 0; } //时间格式转化 $arr = explode('/', substr($_POST['date'], 0, 10)); $date = gmmktime(0, 0, 0, $arr[0], $arr[1], $arr[2]); // print_r($date); $id = $db->insert('ambassador', array('nickname' => $_POST['nickname'], 'ekey' => $_POST['key'], 'pwd' => $hash_pwd, 'auth' => $_POST['auth'], 'date' => $date, 'school' => $_POST['school'], 'province' => $_POST['province'], 'city' => $_POST['city'], 'randdata' => $_POST['randdata'], 'name' => $_POST['name'], 'level' => $level, 'salary' => 0)); //信息和school表进行匹配更新 $school = $db->select('school', '*', array('name' => $_POST['school'])); if (empty($school)) { $db->insert('school', array('name' => $_POST['school'], 'area' => $_POST['province'], 'city' => $_POST['city'])); } else { $db->update('school', array('area' => $_POST['province'], 'city' => $_POST['city']), array('name' => $_POST['school'])); } unset($db); } catch (Exception $e) { echo '<center><h1 style="color: red">添加失败!</h1></center><meta http-equiv="refresh" content="2;url=http://am.erhuoapp.com/' . $type . '/project/htdocs/adduser.php">'; } if ($id > 0) { echo '<center><h1 style="color: chartreuse;">添加成功!</h1></center><meta http-equiv="refresh" content="2;url=http://am.erhuoapp.com/' . $type . '/project/htdocs/adduser.php">'; } else { echo $id;
/** * @param $table * @param $data * @return array */ public function insert($table, $data) { return parent::insert($this->prefix . $table, $data); }
<?php require_once 'meedoo.php'; require_once 'config.php'; $database = new medoo(); session_start(); ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(-1); $email = $_POST["email"]; $name = $_POST["name"]; $password1 = $_POST["password"]; $password = md5($password1 . $salt); //check if user exists $profile = $database->get("users", ["email"], ["email" => $email]); $profile_email = $profile['email']; if ($profile_email) { echo 'emailTaken'; } else { //if not... $add = $database->insert('users', ['email' => $email, 'password' => $password, 'name' => $name]); if ($add) { $_SESSION['user'] = $email; echo 'good'; } else { echo 'bad'; } }
<?php ini_set('odbc.defaultlrl', '1024000'); require 'conf.php'; for ($i = 0; $i <= 200; $i++) { $newmysqldb = new medoo(['server' => '127.0.0.1', 'username' => 'root', 'password' => '', 'database_name' => 'lianchuangcms', 'port' => 3306]); $maxid = $newmysqldb->max('news', 'id'); $maxid == false && ($maxid = 0); //文章表 $sql = 'SELECT TOP(5000) ID,ClassID,Title,keyword,OrderID,Attribute,UserID,CreateDate,UpdateDate,CONVERT(text,Content) as Content,DefaultPic,FromWeb,filename FROM Word where ID >' . $maxid . ' ORDER BY ID ASC'; $exec = odbc_exec($mssqldb, $sql); while ($row = odbc_fetch_array($exec)) { $content = trim(mb_convert_encoding(trim($row['Content']), "UTF-8", "GBK")); $insertid = $newmysqldb->insert('news', ['id' => str_replace('.0', '', $row['ID']), 'catid' => str_replace('.0', '', $row['ClassID']), 'title' => trim(str_replace(" ", '', remove_nbsp(mb_convert_encoding($row['Title'], "UTF-8", "GBK")))), 'keywords' => trim(remove_nbsp(mb_convert_encoding($row['keyword'], "UTF-8", "GBK"))), 'description' => trim(str_replace(" ", '', remove_nbsp(mb_substr(strip_tags($content), 0, 78, 'UTF-8')))), 'listorder' => str_replace('.0', '', $row['OrderID']), 'attribute' => intval($row['Attribute']), 'uid' => str_replace('.0', '', $row['UserID']), 'username' => '', 'url' => '', 'islink' => 0, 'inputtime' => strtotime($row['CreateDate']), 'updatetime' => strtotime($row['UpdateDate']), 'status' => 99]); $newmysqldb->insert('news_data', ['id' => str_replace('.0', '', $row['ID']), 'content' => addslashes(stripslashes($content)), 'defaultpic' => $row['DefaultPic'], 'fromweb' => $row['FromWeb'], 'filename' => $row['filename']]); echo 'insert article success id is ' . $row['ID'] . PHP_EOL; } } function remove_nbsp($str) { $str = mb_ereg_replace('^( | )+', '', $str); $str = mb_ereg_replace('( | )+$', '', $str); $str = mb_ereg_replace(' ', "\n ", $str); $order = array("\r\n", "\n", "\r"); $replace = '<br/>'; $str = str_replace($order, $replace, $str); return $str; }
require 'lib/medoo.php'; try { $database = new medoo(['database_type' => 'mysql', 'database_name' => 'recipe', 'server' => 'localhost', 'username' => 'recipe', 'password' => 'mPu92jfqRJSVMa8H', 'charset' => 'utf8']); $request_body = file_get_contents('php://input'); if ($request_body != null) { $json = json_decode($request_body, true); if ($json['data']) { $json = $json['data']; } $resultObj = array(); if ($json['recipe_id'] != null) { $recipe_id = $json['recipe_id']; $where = ['recipe_id' => $recipe_id]; $result = $database->update("recipe", $json, $where); } else { $result = $database->insert("recipe", $json); $resultObj["recipe_id"] = $result; } print_r(json_encode($resultObj)); } else { $data = $database->select("recipe", "*", []); foreach ($data as &$row) { $ingredients = $database->select("recipe_ingredient", ["[>]ingredient" => "ingredient_id", "[>]measure" => "measure_id"], "*", ["recipe_id" => $row["recipe_id"]]); $row["ingredients"] = $ingredients; foreach ($ingredients as &$ing) { if ($ing["amount"] == 1) { $ing["measure"] = $ing["measure_abbr"]; } else { $ing["measure"] = $ing["measure_plural_abbr"]; } }
<?php require_once 'medoo.php'; $database = new medoo(['database_type' => 'mysql', 'database_name' => 'car', 'server' => 'localhost', 'username' => 'root', 'password' => '', 'charset' => 'utf8']); $database->insert('car_list', ['id' => '', 'name' => $_POST['name'], 'phone' => $_POST['phone'], 'address' => $_POST['address'], 'time' => $_POST['time'], 'carcard' => $_POST['carcard'], 'carmodel' => $_POST['carmodel'], 'projects' => $_POST['projects1'] and $_POST['projects2'] and $_POST['projects3']]); ?> <?php include "thank.php";
<?php require '../vendor/autoload.php'; require '../secrets.php'; $data = json_decode(urldecode($_GET['data']), true); $data['address'] = $_SERVER['REMOTE_ADDR']; $output = array(); $hash = md5($data['address'] . ":" . $data['port']); $disableDB = false; if (!$disableDB) { try { $database = new medoo(['database_type' => 'mysql', 'database_name' => $dbname, 'server' => $dbhost, 'username' => $dbuser, 'password' => $dbpass, 'port' => $dbport, 'charset' => 'utf8']); } catch (Exception $e) { die("Failed to connect to the database\r\n"); } $record = $database->get("server", "id", ["id" => $hash]); if (empty($record)) { $database->insert("server", ["id" => $hash, "address" => $data['address'], "port" => $data['port'], "lastupdate" => time()]); $database->insert("server_details", ["serverid" => $hash, "players" => $data['currentPlayers'], "slots" => $data['maxPlayers'], "memory" => $data['systemRam']]); } else { $database->update("server", ["id" => $hash, "address" => $data['address'], "port" => $data['port'], "lastupdate" => time()], ["id" => $hash]); $database->update("server_details", ["serverid" => $hash, "players" => $data['currentPlayers'], "slots" => $data['maxPlayers'], "memory" => $data['systemRam']], ["serverid" => $hash]); } } $output["success"] = "Ok"; echo json_encode($output);
<?php defined("TEMPLATES_PATH") or define("TEMPLATES_PATH", realpath(dirname(__FILE__) . '/view')); defined("LIBRARY_PATH") or define("LIBRARY_PATH", realpath(dirname(__FILE__) . '/lib')); include LIBRARY_PATH . '/medoo.min.php'; if (isset($_GET['install']) and !file_exists(LIBRARY_PATH . '/database.db') and isset($_POST['username']) and isset($_POST['pwd']) and isset($_POST['rpt']) and $_POST['pwd'] == $_POST['rpt']) { $db = new medoo(LIBRARY_PATH . '/database.db'); $db->query("CREATE TABLE users (username TEXT,password TEXT);"); $db->query("CREATE TABLE settings (setting TEXT,value TEXT);"); $db->query("CREATE TABLE hosts (domain TEXT,checkInTime TEXT,description TEXT);"); $db->insert("users", ["username" => strtolower($_POST['username']), "password" => password_hash($_POST['pwd'], PASSWORD_DEFAULT)]); $db->insert("settings", ["setting" => "secretKey", "value" => rand()]); if (!$db->error()[0] == "00000") { unlink(LIBRARY_PATH . '/database.db'); $noticeMessage = "An error occurred while saving the database."; } else { $noticeMessage = "Successfully installed DropPoint control. Please login."; } } if (!file_exists(LIBRARY_PATH . '/database.db')) { include TEMPLATES_PATH . '/setup.php'; exit; } $db = new medoo(LIBRARY_PATH . '/database.db'); $secretCode = $db->get("settings", "value", ["setting" => "secretKey"]); function dbHasError() { global $db; if ($db->error()[0] == "00000") { return false; } else {
} if ("listAllOP" === $action) { listOP(); header("location: ../../op.php"); } function listOP() { global $database; $allOP = $database->select("gr_op", "*"); $_SESSION["allOP"] = $allOP; } if ("addOP" === $action) { $opid = htmlspecialchars($_GET["opid"]); $opname = htmlspecialchars($_GET["opname"]); $limit = htmlspecialchars($_GET["limit"]); $database->insert("gr_op", ["opid" => $opid, "opname" => $opname, "pw" => "123", "privilege" => $limit]); listOP(); header("location: ../../op.php"); } if ("delOP" === $action) { $opid = htmlspecialchars($_GET["id"]); $opname = $database->select("gr_op", "opname", ["opid" => $opid]); $op = $database->select("gr_charge", "opname", ["opname" => $opname, "LIMIT" => 1]); if (count($op) == 0) { $database->delete("gr_op", ["opid" => $opid]); listOP(); header("location: ../../op.php"); } else { header("location: ../../op.php?error=true"); } }
/** * Created by PhpStorm. * User: KeenSting * Date: 2015/7/8 * Time: 11:53 */ require_once './parameter/Medoo/Resource/medoo.php'; $name = $_POST['name']; $sex = $_POST['sex']; $dep = $_POST['depart']; $pos = $_POST['position']; $tel = $_POST['tel']; $mail = $_POST['mail']; $mydb = new medoo('meetingmanage'); $id = $mydb->max('user', 'USER_ID'); $mydb->insert('user', array('USER_ID' => $id + 1, 'EMAIL' => $mail, 'PHONE' => $tel, 'NAME' => $tel, 'REAL_NAME' => $name, 'PWD' => $tel, 'IDENTY' => $pos, 'HEAD_IMG' => './assert/user/headimg/4.jpg', 'SEX' => $sex, 'DEPART_ID' => $dep, 'STATE' => 1, 'MES' => 0)); ?> <html> <head> </head> <body> <script> alert('员工信息已添加,手机号即为登录账号和密码!'); </script> </body> <meta http-equiv="refresh" content="1;url='./addperson.php'"> </html>
// todo,inform 中增加一项 //todo,1,attendence中检索meeting id,2,对应状态state设置为0 无效,3,对应user id写成新的notice,4,并将user表中的mes改为当前inform_id $mid = $_POST['id']; session_start(); $id = $_SESSION['uid']; include '../../parameter/Medoo/Resource/medoo.php'; //meeting $db = new medoo('meetingmanage'); $db->update('meeting', array('VALIDITY' => 1), array('MEETING_ID' => $mid)); // ////inform $re = $db->select('inform', 'CONTENT', array('MEETING_ID' => 40002)); $content = $re[0]; $new_mes = "注意:关于【" . $content . "】的会议已经取消,请您确认信息!"; $iid = $db->max('inform', 'INFORM_ID'); $iid += 1; $date = date("Y/m/d"); $db->insert("inform", array('INFORM_ID' => $iid, 'USER_ID' => $id, 'DATE' => $date, 'CONTENT' => $new_mes, 'MEETING_ID' => $mid)); //attendence //获得user列表 $users = $db->select('attendence', 'USER_ID', array('MEETING_ID' => 40000)); //跟新参会状态 $db->update('attendence', array('STATE' => 0), array('MEETING_ID' => $mid)); //notice & user $num = count($users); $nid = $db->max('notice', 'NOTICE_ID'); $nid += 1; for ($i = 0; $i < $num; $i++) { $db->insert('notice', array('NOTICE_ID' => $nid, 'USER_ID' => $users[$i], 'INFORM_ID' => $iid, 'STATE' => 0)); $db->update('user', array('MES' => $iid), array('USER_ID' => $users[$i])); }
$rawArr = $_POST; //grab out name/email $insertArr = array( "enteredName" => $rawArr[$cf.'enteredName'], "email" => $rawArr[$cf.'email'], "status" => 'new', "#createdDate" => "NOW()", "quizid" => $rawArr['quizid'], ); //unset those vars, so that we're left with the answers unset($rawArr[$cf.'enteredName']); unset($rawArr[$cf.'email']); unset($rawArr['quizid']); $rawData = json_encode($rawArr); $insertArr['rawData'] = $rawData; $shoveItIn = $db->insert("quizResult",$insertArr); $quizresult = $db->select("quizResult",array("quizresultid"),array("rawData"=>$rawData)); //Now to break down the answers unset($rawArr['codefieldName']); foreach($rawArr as $k => $v) { //split keys on question. Split value on pipe $questionData = explode("question",$k); //here can add more security if needed to check to make sure it's same student. Not checking now though $answerData = explode("|",$v); //case where answer doesn't have id?! if (!empty($answerData[1])) { $answerid = $answerData[0]; $answer = $answerData[1]; } else { $answerid =0; $answer = $answerData[0];