来源:自学PHP网 时间:2015-04-16 23:15 作者: 阅读:次
[导读] 问题发生在app controller user class php146行public function update() {$_Obj = M ( 39;user 39; );if (($_POST [ 39;info 39;] [ 39;password 39;] !== $_POST [ 39;password1 39;])...
问题发生在
app\controller\user.class.php
146行
public function update() { $_Obj = M ( 'user' ); if (($_POST ['info'] ['password'] !== $_POST ['password1'])) { StringUtil::msgbox ( Config::lang ( "PWDNOTTHESAME" ), 'index.php?ac=users_info', 1 ); exit (); } $_Obj->create (); if ($_POST ['info'] ['password'] != "" && ($_POST ['info'] [password] == $_POST ['password1'])) { $_Obj->password = strlen ( $_POST ['info'] ['password'] ) > 15 ? $_POST ['info'] ['password'] : md5 ( $_POST ['info'] ['password'] ); } if (empty ( $_POST ['info'] ['area'] )) { $_Obj->area = ""; } if (empty ( $_POST ['info'] ['city'] )) { $_Obj->city = ""; } //禁止修改管理员 $userObj = get ( "user", $_Obj->id ); if ($userObj->grade == 1) { self::checkIsAdmin (); } //禁止修改别人的 $IsSelfData = Authen::checkIsSelfData ( $_Obj->id ); if (! $IsSelfData) { $this->setValue ( "error", Config::lang ( "NOTRIGHT" ) ); $this->forward ( "error.html" ); exit (); } $_Obj->update (); StringUtil::msgbox ( Config::lang ( "MODIFYSUCCESS" ), 'index.php?ac=user_info', 1 ); }
这里调用了 $_Obj->create ();
学TP!
然后在看看
$_Obj->create (); 这个里面什么情况
public function create($datas = '') { $data = array(); $data = $datas; if (empty($data)) { $data = $_POST['info']; } elseif (is_object($data)) { $data = get_object_vars($data); } elseif (!is_array($data)) { $msg = Config::lang("ILLEGALDATA"); exit($msg); } if (empty($_POST['info']) && empty($data)) { return false; } $fieldsType = $this->types; //字段和默认值 $fieldsName = $this->fields; //字段和类型 $formKeyAry = array_keys($data); //post过来的所有$key /* @var $key type */ foreach ($formKeyAry as $key) { if (array_key_exists($key, $this->fields)) { $val = isset($data[$key]) ? $data[$key] : NULL; if (is_scalar($val)) { if (false !== strpos($fieldsType[$key], 'int')) { $val = intval($val); } elseif (false !== strpos($fieldsType[$key], 'float') || false !== strpos($fieldsType[$key], 'double')) { $val = floatval($val); } } if (!is_null($val)) { $this->$key = $val; } if (($data[$key] == "" || $data[$key] == NULL || $data[$key] === 0) && $fieldsName[$key] != "") { $this->$key = $fieldsName[$key]; } } } return $this; }
$_POST['info'][xx] xx 直接是数据库字段 可以成功修改!
在
http://www.teamcen.com/index.php?ac=user_info
页面通过修改表单名称 成功把注册的普通帐号修改为了管理员帐号
|
自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习
京ICP备14009008号-1@版权所有www.zixuephp.com
网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com