コード例 #1
0
ファイル: Node.php プロジェクト: cnlangzi/wifidog-auth
 /** @param $id The id of the node
  * @param $idType 'NODE_ID' or 'GATEWAY_ID'*/
 protected function __construct($id, $idType = 'NODE_ID')
 {
     $db = AbstractDb::getObject();
     $this->mDb =& $db;
     $id_str = $db->escapeString($id);
     switch ($idType) {
         case 'NODE_ID':
             $sqlWhere = "node_id='{$id_str}'";
             break;
         case 'GATEWAY_ID':
             $sqlWhere = "gw_id='{$id_str}'";
             break;
         default:
             throw new exception('Unknown idType parameter');
     }
     $sqlWhere = $sql = "SELECT * FROM nodes WHERE {$sqlWhere}";
     $row = null;
     $db->execSqlUniqueRes($sql, $row, false);
     if ($row == null) {
         throw new Exception(sprintf(_("The node with %s: %s could not be found in the database!"), $idType, $id_str));
     }
     $this->_deploymentStatuses = array("DEPLOYED" => _("Deployed"), "IN_PLANNING" => _("In planning"), "IN_TESTING" => _("In testing"), "NON_WIFIDOG_NODE" => _("Non-Wifidog node"), "PERMANENTLY_CLOSED" => _("Permanently closed"), "TEMPORARILY_CLOSED" => _("Temporarily closed"));
     $this->_row = $row;
     $this->id = $row['node_id'];
     parent::__construct($this->id, 'Node');
 }
コード例 #2
0
ファイル: Network.php プロジェクト: cnlangzi/wifidog-auth
 /**
  * Constructor
  *
  * @param string $p_network_id
  *
  * @return void
  *
  * @access private
  */
 protected function __construct($p_network_id)
 {
     $db = AbstractDb::getObject();
     if ($p_network_id == "") {
         $p_network_id = self::getDefaultNetwork()->getId();
     }
     $network_id_str = $db->escapeString($p_network_id);
     $sql = "SELECT *, EXTRACT(EPOCH FROM validation_grace_time) as validation_grace_time_seconds FROM networks WHERE network_id='{$network_id_str}'";
     $row = null;
     $db->execSqlUniqueRes($sql, $row, false);
     if ($row == null) {
         throw new Exception("The network with id {$network_id_str} could not be found in the database");
     }
     $this->_row = $row;
     $this->_id = $p_network_id;
     parent::__construct($this->_id, 'Network');
 }
コード例 #3
0
ファイル: NodeGroup.php プロジェクト: cnlangzi/wifidog-auth
 /** @param $id The id of the node group
  * @param $idType 'GROUP_ID' or 'NAME'*/
 protected function __construct($id, $idType = 'GROUP_ID')
 {
     $db = AbstractDb::getObject();
     $this->mDb =& $db;
     $id_str = $db->escapeString($id);
     switch ($idType) {
         case 'GROUP_ID':
             $sqlWhere = "node_group_id='{$id_str}'";
             break;
         case 'NAME':
             $sqlWhere = "name='{$id_str}'";
             break;
         default:
             throw new exception('Unknown idType parameter');
     }
     $sqlWhere = $sql = "SELECT * FROM node_groups WHERE {$sqlWhere}";
     $row = null;
     $db->execSqlUniqueRes($sql, $row, false);
     if ($row == null) {
         throw new Exception(sprintf(_("The node group with %s: %s could not be found in the database!"), $idType, $id_str));
     }
     $this->_row = $row;
     $this->id = $row['node_group_id'];
     parent::__construct($this->id, 'NodeGroup');
 }