# New Features ## What feature(s) did you add? - Migrate the whole IOT system project to ThinkPHP v5 framework  - Update the login function .Consider more secure factors like sql injection ### **Before**: When i come to login interface in the old version without thinkphp ,I input "admin' AND 1=1 -- " into the username blank and input any other text into password blank even though that is a wrong password. It will show like this:   ### Now: Input the same as above step,then the thinkphp framework will filter the user input then show like this:   But to a certain extent,ThinkPHP may also have some vulnerable bugs leading to be hacked. --- # How did you implement it/them? - **IOT/webMonitor/thinkphp v5/thinkphp5/application/index/controller/Login.php** ``` <?php namespace app\index\controller; use think\Controller; use think\Cookie; class Login extends Controller { public function index() { return $this->fetch(); } public function login() { $post_data = input('post.'); $username = $post_data['username']; $password = $post_data['password']; if(empty($username)) { $this->error('please input username'); } if(empty($password)) { $this->error('please input password'); } $valid = db('user')->where('username', $username)->find(); if(empty($valid)){ $this->error('username or password error!'); } if($valid['password'] != md5($password)){ $this->error('username or password error!'); } cookie('username', $valid['username'], 3600); $this->redirect(url('index/index')); } } ``` When do some mysql operation , use the ThinkPHP internal sql function to realize the login function. ``` db('user')->where('username', $username)->find() ``` - **IOT/webMonitor/thinkphp v5/thinkphp5/application/index/controller/Sensorsdata.php** ``` <?php namespace app\index\controller; use think\Controller; use think\Cookie; class Sensorsdata extends Controller { public function index() { if(cookie::has('username')) { $ID = 0; $dataset = db('device')->where('ID', $ID)->find(); $data_airQuality = $dataset['data_airQuality']; $data_distance = $dataset['data_distance']; $data_voice = $dataset['data_voice']; $data_light = $dataset['data_light']; $data_humi = $dataset['data_humi']; $data_temp = $dataset['data_temp']; $data = array( 'temp'=>$data_temp, 'humi'=>$data_humi, 'light'=>$data_light, 'voice'=>$data_voice, 'airquality'=>$data_airQuality, 'distance'=>$data_distance ); return json_encode($data); } // return $this->fetch(); else { $this->error('Please login first'); $this->redirect(url('login/index')); } } } ``` Get sensors data in real time from the ESP8266 hardware and send them to the web UI. - **Split frontend and backend** The project list is as below: - controller - Index,php - Login.php - Sensorsdata.php - view - index - index.html - login - index.html --- ## Roadmap - Considering when the IOT system is used into actual, there are many devices instead of one of two .So it is necessary to add a devices manager function to help use it Conveniently. - Identify different devices by their ID - Consider the performance of the communication protocol .May use MQTT protocol in the future version. - Add other control way like discord controlling . --- ## How to contribute? Github: <https://github.com/Cha0s0000/IOT> - Fork it! - Create your feature branch: `git checkout -b my-new-feature` - Commit your changes: `git commit -am 'Add some feature'` - Push to the branch: `git push origin my-new-feature` - Submit a pull request. <br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@cha0s0000/iot-project-use-thinkphp-as-the-iot-system-project-framework">Utopian.io - Rewarding Open Source Contributors</a></em><hr/>
author | cha0s0000 | ||||||
---|---|---|---|---|---|---|---|
permlink | iot-project-use-thinkphp-as-the-iot-system-project-framework | ||||||
category | utopian-io | ||||||
json_metadata | {"community":"utopian","app":"utopian/1.0.0","format":"markdown","repository":{"id":120746740,"name":"IOT","full_name":"Cha0s0000/IOT","html_url":"https://github.com/Cha0s0000/IOT","fork":false,"owner":{"login":"Cha0s0000"}},"pullRequests":[],"platform":"github","type":"development","tags":["utopian-io","steemstem","development","steemdev","iot"],"links":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1519283372/yavwwxqh3aoslmu0wvkk.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1519284286/lp0kp5t087olkvs8m9or.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1519283756/j4fjizxzvyh12dh0a66n.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1519284315/vqy1hbelr8luw3ocn1wh.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1519288874/dpuckncenn2t4x5nlkxy.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1519284373/ocikgntl1fwfaxhqpvrz.png"],"image":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1519283372/yavwwxqh3aoslmu0wvkk.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1519284286/lp0kp5t087olkvs8m9or.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1519283756/j4fjizxzvyh12dh0a66n.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1519284315/vqy1hbelr8luw3ocn1wh.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1519288874/dpuckncenn2t4x5nlkxy.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1519284373/ocikgntl1fwfaxhqpvrz.png"],"moderator":{"account":"wehmoen","time":"2018-02-25T17:41:33.724Z","reviewed":true,"pending":false,"flagged":false},"questions":[],"score":0} | ||||||
created | 2018-02-22 08:41:42 | ||||||
last_update | 2018-02-25 17:41:33 | ||||||
depth | 0 | ||||||
children | 5 | ||||||
last_payout | 2018-03-01 08:41:42 | ||||||
cashout_time | 1969-12-31 23:59:59 | ||||||
total_payout_value | 38.508 HBD | ||||||
curator_payout_value | 16.242 HBD | ||||||
pending_payout_value | 0.000 HBD | ||||||
promoted | 0.000 HBD | ||||||
body_length | 4,993 | ||||||
author_reputation | 30,983,518,016,225 | ||||||
root_title | "IOT project -- Use ThinkPHP as the IOT system project framework" | ||||||
beneficiaries |
| ||||||
max_accepted_payout | 1,000,000.000 HBD | ||||||
percent_hbd | 10,000 | ||||||
post_id | 39,555,496 | ||||||
net_rshares | 12,094,776,635,045 | ||||||
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
team | 0 | 81,326,423,235 | 10% | ||
miniature-tiger | 0 | 71,472,470,461 | 100% | ||
mys | 0 | 35,950,098,766 | 50% | ||
codingdefined | 0 | 8,131,234,425 | 25% | ||
tvb | 0 | 13,165,969,533 | 30% | ||
vandadream | 0 | 4,248,262,301 | 100% | ||
utopian-io | 0 | 11,855,701,838,792 | 9.56% | ||
lebin | 0 | 20,515,439,382 | 30% | ||
enjoyy | 0 | 2,065,191,075 | 100% | ||
steemnova | 0 | 2,199,707,075 | 50% |
Thanks for sharing although I couldn't understand it much.
author | enjoyy |
---|---|
permlink | re-cha0s0000-iot-project-use-thinkphp-as-the-iot-system-project-framework-20180223t004233918z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-02-23 00:38:00 |
last_update | 2018-02-23 00:38:00 |
depth | 1 |
children | 0 |
last_payout | 2018-03-02 00:38:00 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 58 |
author_reputation | 342,844,941,159 |
root_title | "IOT project -- Use ThinkPHP as the IOT system project framework" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 39,730,714 |
net_rshares | 0 |
### Hey @cha0s0000 I am @utopian-io. I have just upvoted you! #### Achievements - You have less than 500 followers. Just gave you a gift to help you succeed! - Seems like you contribute quite often. AMAZING! #### Community-Driven Witness! I am the first and only Steem Community-Driven Witness. <a href="https://discord.gg/zTrEMqB">Participate on Discord</a>. Lets GROW TOGETHER! - <a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1">Vote for my Witness With SteemConnect</a> - <a href="https://v2.steemconnect.com/sign/account-witness-proxy?proxy=utopian-io&approve=1">Proxy vote to Utopian Witness with SteemConnect</a> - Or vote/proxy on <a href="https://steemit.com/~witnesses">Steemit Witnesses</a> [](https://steemit.com/~witnesses) **Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x**
author | utopian-io |
---|---|
permlink | re-cha0s0000-iot-project-use-thinkphp-as-the-iot-system-project-framework-20180226t173330698z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"} |
created | 2018-02-26 17:33:30 |
last_update | 2018-02-26 17:33:30 |
depth | 1 |
children | 0 |
last_payout | 2018-03-05 17:33:30 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,085 |
author_reputation | 152,955,367,999,756 |
root_title | "IOT project -- Use ThinkPHP as the IOT system project framework" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 40,652,365 |
net_rshares | 0 |
author | wehmoen |
---|---|
permlink | re-cha0s0000-iot-project-use-thinkphp-as-the-iot-system-project-framework-20180225t175102162z |
category | utopian-io |
json_metadata | {} |
created | 2018-02-25 17:51:12 |
last_update | 2020-06-03 06:49:45 |
depth | 1 |
children | 2 |
last_payout | 2018-03-04 17:51:12 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.823 HBD |
curator_payout_value | 0.273 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1 |
author_reputation | 86,504,380,503,125 |
root_title | "IOT project -- Use ThinkPHP as the IOT system project framework" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 40,388,712 |
net_rshares | 197,498,796,672 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
utopian.tip | 0 | 197,498,796,672 | 18.97% |
thanks your work.I will next time
author | cha0s0000 |
---|---|
permlink | re-wehmoen-re-cha0s0000-iot-project-use-thinkphp-as-the-iot-system-project-framework-20180226t002844938z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-02-26 00:28:45 |
last_update | 2018-02-26 00:28:45 |
depth | 2 |
children | 0 |
last_payout | 2018-03-05 00:28:45 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 33 |
author_reputation | 30,983,518,016,225 |
root_title | "IOT project -- Use ThinkPHP as the IOT system project framework" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 40,455,555 |
net_rshares | 0 |
Hey @wehmoen, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!
author | utopian.tip |
---|---|
permlink | re-re-cha0s0000-iot-project-use-thinkphp-as-the-iot-system-project-framework-20180225t175102162z-20180226t003848 |
category | utopian-io |
json_metadata | "" |
created | 2018-02-26 00:38:48 |
last_update | 2018-02-26 00:38:48 |
depth | 2 |
children | 0 |
last_payout | 2018-03-05 00:38:48 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 157 |
author_reputation | 238,310,597,885 |
root_title | "IOT project -- Use ThinkPHP as the IOT system project framework" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 40,457,326 |
net_rshares | 0 |