コード例 #1
0
 function add_post()
 {
     $this->_getTree();
     if (IS_POST) {
         if (!empty($_POST['photos_alt']) && !empty($_POST['photos_url'])) {
             foreach ($_POST['photos_url'] as $key => $url) {
                 $photourl = sp_asset_relative_url($url);
                 $_POST['smeta']['photo'][] = array("url" => $photourl, "alt" => $_POST['photos_alt'][$key]);
             }
         }
         $_POST['smeta']['thumb'] = sp_asset_relative_url($_POST['smeta']['thumb']);
         $_POST['post']['post_date'] = date("Y-m-d H:i:s", time());
         $_POST['post']['smeta'] = json_encode($_POST['smeta']);
         $_POST['post']['post_author'] = get_current_admin_id();
         $result = $this->posts_obj->add($_POST['post']);
         if ($result) {
             //
             $_POST['term']['object_id'] = $result;
             $result = $this->terms_relationship->add($_POST['term']);
             if ($result) {
                 $this->success("添加成功!");
             } else {
                 $this->error("归类失败!");
             }
         } else {
             $this->error("添加失败!");
         }
     }
 }
コード例 #2
0
 function add_post()
 {
     if (IS_POST) {
         if (empty($_POST['term'])) {
             $this->error("请至少选择一个分类栏目!");
         }
         if (!empty($_POST['photos_alt']) && !empty($_POST['photos_url'])) {
             foreach ($_POST['photos_url'] as $key => $url) {
                 $photourl = sp_asset_relative_url($url);
                 $_POST['smeta']['photo'][] = array("url" => $photourl, "alt" => $_POST['photos_alt'][$key]);
             }
         }
         $_POST['smeta']['thumb'] = sp_asset_relative_url($_POST['smeta']['thumb']);
         $_POST['post']['post_date'] = date("Y-m-d H:i:s", time());
         $_POST['post']['post_author'] = get_current_admin_id();
         $article = I("post.post");
         $article['smeta'] = json_encode($_POST['smeta']);
         $article['post_content'] = htmlspecialchars_decode($article['post_content']);
         $result = $this->posts_model->add($article);
         if ($result) {
             //
             foreach ($_POST['term'] as $mterm_id) {
                 $this->term_relationships_model->add(array("term_id" => intval($mterm_id), "object_id" => $result));
             }
             $this->success("添加成功!");
         } else {
             $this->error("添加失败!");
         }
     }
 }
コード例 #3
0
 function password_post()
 {
     if (IS_POST) {
         if (empty($_POST['old_password'])) {
             $this->error("原始密码不能为空!");
         }
         if (empty($_POST['password'])) {
             $this->error("新密码不能为空!");
         }
         $user_obj = D("Common/Users");
         $uid = get_current_admin_id();
         $admin = $user_obj->where(array("id" => $uid))->find();
         $old_password = $_POST['old_password'];
         $password = $_POST['password'];
         if (sp_password($old_password) == $admin['user_pass']) {
             if ($_POST['password'] == $_POST['repassword']) {
                 if ($admin['user_pass'] == sp_password($password)) {
                     $this->error("新密码不能和原始密码相同!");
                 } else {
                     $data['user_pass'] = sp_password($password);
                     $data['id'] = $uid;
                     $r = $user_obj->save($data);
                     if ($r !== false) {
                         $this->success("修改成功!");
                     } else {
                         $this->error("修改失败!");
                     }
                 }
             } else {
                 $this->error("密码输入不一致!");
             }
         } else {
             $this->error("原始密码不正确!");
         }
     }
 }
コード例 #4
0
 function userinfo_post()
 {
     if (IS_POST) {
         $_POST['id'] = get_current_admin_id();
         $create_result = $this->users_obj->field("user_login,user_email,last_login_ip,last_login_time,create_time,user_activation_key,user_status,role_id,score,user_type", true)->create();
         if ($create_result) {
             if ($this->users_obj->save() !== false) {
                 $this->success("保存成功!");
             } else {
                 $this->error("保存失败!");
             }
         } else {
             $this->error($this->users_obj->getError());
         }
     }
 }
コード例 #5
0
ファイル: function.php プロジェクト: noikiy/luokeke2
function sp_get_current_admin_id()
{
    return get_current_admin_id();
}
コード例 #6
0
 function add_post()
 {
     if (IS_POST) {
         $_POST['smeta']['thumb'] = sp_asset_relative_url($_POST['smeta']['thumb']);
         $_POST['post']['post_date'] = date("Y-m-d H:i:s", time());
         $_POST['post']['post_author'] = get_current_admin_id();
         $page = I("post.post");
         $page['smeta'] = json_encode($_POST['smeta']);
         $page['post_content'] = htmlspecialchars_decode($page['post_content']);
         $result = $this->posts_model->add($page);
         if ($result) {
             $this->success("添加成功!");
         } else {
             $this->error("添加失败!");
         }
     }
 }
コード例 #7
0
 function userinfo()
 {
     $id = get_current_admin_id();
     $user = $this->users_obj->where(array("id" => $id))->find();
     $this->assign($user);
     $this->display();
 }
コード例 #8
0
 function add_post()
 {
     if (IS_POST) {
         $_POST['smeta']['thumb'] = sp_asset_relative_url($_POST['smeta']['thumb']);
         $_POST['post']['post_date'] = date("Y-m-d H:i:s", time());
         $_POST['post']['smeta'] = json_encode($_POST['smeta']);
         $_POST['post']['post_author'] = get_current_admin_id();
         $result = $this->posts_obj->add($_POST['post']);
         if ($result) {
             $this->success("添加成功!");
         } else {
             $this->error("添加失败!");
         }
     }
 }
コード例 #9
0
 function userinfo()
 {
     $id = get_current_admin_id();
     $user = $this->users_obj->where("ID='{$id}'")->find();
     $this->assign($user);
     $this->display();
 }