You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$info = $pdo->query("select id from consumer where consumer_key = '".$key."'"); // this is not safe !
if($info->rowCount()==1){
$info = $info->fetch();
$consumer = newConsumer($info['id']);
}
return$consumer;
}
publicfunction__construct($id = 0){
$this->pdo = Db::singleton();
if($id != 0){
$this->id = $id;
$this->load();
}
}
privatefunctionload(){
$info = $this->pdo->query("select * from consumer where id = '".$this->id."'")->fetch();
$this->id = $this->id;
$this->key = $info['consumer_key'];
$this->secret = $info['consumer_secret'];
$this->active = $info['active'];
}
publicstaticfunctioncreate($key,$secret){
$pdo = Db::singleton();
$pdo->exec("insert into consumer (consumer_key,consumer_secret,active) values ('".$key."','".$secret."',1)");
$consumer = newConsumer($pdo->lastInsertId());
return$consumer;
}
publicfunctionisActive(){
return$this->active;
}
publicfunctiongetKey(){
return$this->key;
}
publicfunctiongetSecretKey(){
return$this->secret;
}
publicfunctiongetId(){
return$this->id;
}
publicfunctionhasNonce($nonce,$timestamp){
$check = $this->pdo->query("select count(*) as cnt from consumer_nonce where timestamp = '".$timestamp."' and nonce = '".$nonce."' and consumer_id = ".$this->id)->fetch();
if($check['cnt']==1){
returntrue;
} else {
returnfalse;
}
}
publicfunctionaddNonce($nonce){
$check = $this->pdo->exec("insert into consumer_nonce (consumer_id,timestamp,nonce) values (".$this->id.",".time().",'".$nonce."')");