当前位置: 首页>>代码示例>>PHP>>正文


PHP Password::add方法代码示例

本文整理汇总了PHP中Password::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Password::add方法的具体用法?PHP Password::add怎么用?PHP Password::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Password的用法示例。


在下文中一共展示了Password::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: check_add

 private function check_add()
 {
     if (!empty($_POST['add'])) {
         $title = isset($_POST['title']) ? $_POST['title'] : false;
         $website = isset($_POST['website']) ? $_POST['website'] : false;
         $username = isset($_POST['username']) ? $_POST['username'] : false;
         $password = isset($_POST['password']) ? $_POST['password'] : false;
         if (empty($title) or empty($password)) {
             return "Title or Password missing!";
         } else {
             $password_obj = new Password($this->nextpass->db, $this->nextpass->account, $this->nextpass->debug);
             $add_password = $password_obj->add($title, $website, $username, $password);
             if ($add_password !== true) {
                 return "Something went wrong!";
             } else {
                 $this->message = "Password added successfully!";
                 return true;
             }
         }
     } else {
         return false;
     }
 }
开发者ID:NextPass,项目名称:NextPass,代码行数:23,代码来源:add.php

示例2: generate_html

 public function generate_html()
 {
     // allow the api to be accessed from outside the server
     header("Access-Control-Allow-Origin: *");
     $answer = array();
     if ($this->subpage1 == "status") {
         $answer['version'] = "0.1";
         $answer['secure'] = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443;
     } else {
         if ($this->subpage1 == "login") {
             if (empty($_POST['username']) or empty($_POST['password'])) {
                 $answer['error'] = "Missing Username or Password";
             } else {
                 if ($this->nextpass->account->logged_in === true) {
                     $answer['error'] = "Already logged in!";
                 } else {
                     $username = $_POST['username'];
                     $password = $_POST['password'];
                     $login = $this->nextpass->account->login($username, $password);
                     if ($login !== true) {
                         $answer['error'] = "Wrong E-Mail/Username or Password!";
                     }
                 }
             }
         } else {
             if ($this->subpage1 == "check_login") {
                 $answer['login_status'] = $this->nextpass->account->logged_in;
             } else {
                 if ($this->subpage1 == "logout") {
                     if ($this->nextpass->account->logged_in !== true) {
                         $answer['error'] = "Already logged out!";
                     } else {
                         $logout = $this->nextpass->account->logout();
                         if ($logout !== true) {
                             $answer['error'] = "Unknown Error!";
                         }
                     }
                 } else {
                     if ($this->subpage1 == "get_passwords_for_website") {
                         if ($this->nextpass->account->logged_in !== true) {
                             $answer['error'] = "Not logged in!";
                         } else {
                             if (empty($_POST['website'])) {
                                 $answer['error'] = "Missing Website";
                             } else {
                                 $password_list = new PasswordList($this->nextpass->html_code, $this->nextpass->db, $this->nextpass->account, $this->nextpass->debug);
                                 $password_list->set_website($_POST['website']);
                                 $passwords = $password_list->generate_array();
                                 $answer['passwords'] = $passwords;
                             }
                         }
                     } else {
                         if ($this->subpage1 == "get_password_list") {
                             if ($this->nextpass->account->logged_in !== true) {
                                 $answer['error'] = "Not logged in!";
                             } else {
                                 $password_list = new PasswordList($this->nextpass->html_code, $this->nextpass->db, $this->nextpass->account, $this->nextpass->debug);
                                 $password_list->set_category(0);
                                 $passwords = $password_list->generate_array();
                                 $answer['passwords'] = $passwords;
                             }
                         } else {
                             if ($this->subpage1 == "get_password") {
                                 if ($this->nextpass->account->logged_in !== true) {
                                     $answer['error'] = "Not logged in!";
                                 } else {
                                     if (empty($this->subpage2) or !ctype_digit($this->subpage2)) {
                                         $answer['error'] = "Missing password id";
                                     } else {
                                         $password_obj = new Password($this->nextpass->db, $this->nextpass->account, $this->nextpass->debug);
                                         $found = $password_obj->set_id($this->subpage2);
                                         if ($found === false) {
                                             $answer['error'] = "Could not find Password";
                                         } else {
                                             $answer['title'] = $password_obj->get_title();
                                             $answer['website'] = $password_obj->get_website();
                                             $answer['username'] = $password_obj->get_username();
                                             $answer['password'] = $password_obj->show();
                                         }
                                     }
                                 }
                             } else {
                                 if ($this->subpage1 == "edit_password" or $this->subpage1 == "add_password") {
                                     if ($this->nextpass->account->logged_in !== true) {
                                         $answer['error'] = "Not logged in!";
                                     } else {
                                         if ($this->subpage1 == "edit_password" and (empty($this->subpage2) or !ctype_digit($this->subpage2))) {
                                             $answer['error'] = "Missing password id";
                                         } else {
                                             if (empty($_POST['password'])) {
                                                 $answer['error'] = "Missing password array";
                                             } else {
                                                 if ($this->subpage1 == "edit_password") {
                                                     $old_password_obj = new Password($this->nextpass->db, $this->nextpass->account, $this->nextpass->debug);
                                                     $old_password_obj->set_id($this->subpage2);
                                                 }
                                                 $password = json_decode($_POST['password'], true);
                                                 $title = isset($password['title']) ? $password['title'] : false;
                                                 $website = isset($password['website']) ? $password['website'] : false;
                                                 $username = isset($password['username']) ? $password['username'] : false;
//.........这里部分代码省略.........
开发者ID:NextPass,项目名称:NextPass,代码行数:101,代码来源:api.php


注:本文中的Password::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。