74 lines
1.5 KiB
PHP
74 lines
1.5 KiB
PHP
<?php
|
|
|
|
class WebAppRaiserFile {
|
|
private $fid;
|
|
private $war_user_id;
|
|
|
|
|
|
|
|
public function __construct($fid) {
|
|
|
|
|
|
$sql = "SELECT * FROM war_files WHERE fid = {$fid}";
|
|
|
|
$q = mysql_query($sql);
|
|
$r = mysql_fetch_assoc($q);
|
|
|
|
if (!empty($r)) {
|
|
$this->fid = $r['fid'];
|
|
//$this->war_username = $r['username'];
|
|
//$user->api['war_expires_in'] = $r['expires_in'];
|
|
//if(empty($r['expires_in'])) {
|
|
// $this->war_expired = NULL;
|
|
//}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function save($fields)
|
|
{
|
|
// valid_fields format: 'form data field' => 'DB data field'
|
|
$valid_fields = array(
|
|
'war_id'=> 'id',
|
|
'war_user_id'=> 'user_id',
|
|
'war_username'=> 'username',
|
|
'war_client_id'=> 'client_id',
|
|
'war_client_secret'=> 'client_secret',
|
|
'war_access_token'=> 'access_token',
|
|
'war_refresh_token'=> 'refresh_token',
|
|
'war_expires_in'=> 'expires_in',
|
|
'war_token_type'=> 'token_type',
|
|
);
|
|
//$match_fields = self::matchFieldsToSave($fields, $valid_fields);
|
|
|
|
if (empty($match_fields['fields_to_save']['id'])) {
|
|
//$sql = "INSERT INTO `user_api_war` ($match_fields[field_names]) VALUES ($match_fields[field_values])";
|
|
mysql_query($sql);
|
|
$id = mysql_insert_id();
|
|
}
|
|
else {
|
|
//$id = $match_fields['fields_to_save']['id'];
|
|
//$sql = "UPDATE `user_api_war` SET $match_fields[field_set] WHERE id=$id";
|
|
mysql_query($sql);
|
|
}
|
|
return $id;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function get($name){
|
|
if(isset($this->$name)) {
|
|
return $this->$name;
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
}
|
|
|