Model\Node::getSupportCustomMethodArray PHP Method

getSupportCustomMethodArray() public static method

get support custom method node.
public static getSupportCustomMethodArray ( ) : Node[]
return Node[]
    public static function getSupportCustomMethodArray()
    {
        $plan = User::getCurrent()->plan;
        $selectSQL = 'SELECT * FROM node WHERE custom_method=1 AND `type` BETWEEN 0 AND ?';
        $type = 0;
        if ($plan == 'VIP') {
            $type = 1;
        }
        $statement = DB::getInstance()->prepare($selectSQL);
        $statement->bindValue(1, $type);
        $statement->execute();
        return $statement->fetchAll(DB::FETCH_CLASS, __CLASS__);
    }

Usage Example

Example #1
0
 /**
  * 修改 自定义加密方式
  * @JSON
  * @throws Error
  */
 public function changeMethod()
 {
     $user = User::getCurrent();
     if ($_POST['method'] != null) {
         $method = null;
         if ($_POST['method'] != '-1') {
             $method = htmlspecialchars(trim($_POST['method']));
         }
         $user = User::getUserByUserId($user->uid);
         $user->method = $method;
         $user->save();
         $_SESSION['currentUser'] = $user;
         return array('error' => 0, 'message' => '修改加密方式成功,全部节点同步大约5分钟内生效。');
     } else {
         $nodeList = Node::getSupportCustomMethodArray();
         Template::putContext('user', $user);
         Template::putContext('nodeList', $nodeList);
         Template::setView("panel/changeMethod");
     }
 }