|
|
|
|
@ -4,12 +4,6 @@ class OC_remoteStorage { |
|
|
|
|
public static function getValidTokens($ownCloudUser, $userAddress, $dataScope) { |
|
|
|
|
$query=OC_DB::prepare("SELECT token,appUrl FROM *PREFIX*authtoken WHERE user=? AND userAddress=? AND dataScope=? LIMIT 100"); |
|
|
|
|
$result=$query->execute(array($ownCloudUser,$userAddress,$dataScope)); |
|
|
|
|
if( PEAR::isError($result)) { |
|
|
|
|
$entry = 'DB Error: "'.$result->getMessage().'"<br />'; |
|
|
|
|
$entry .= 'Offending command was: '.$result->getDebugInfo().'<br />'; |
|
|
|
|
OC_Log::write('removeStorage',$entry,OC_Log::ERROR); |
|
|
|
|
die( $entry ); |
|
|
|
|
} |
|
|
|
|
$ret = array(); |
|
|
|
|
while($row=$result->fetchRow()){ |
|
|
|
|
$ret[$row['token']]=$userAddress; |
|
|
|
|
@ -21,12 +15,6 @@ class OC_remoteStorage { |
|
|
|
|
$user=OC_User::getUser(); |
|
|
|
|
$query=OC_DB::prepare("SELECT token,appUrl,userAddress,dataScope FROM *PREFIX*authtoken WHERE user=? LIMIT 100"); |
|
|
|
|
$result=$query->execute(array($user)); |
|
|
|
|
if( PEAR::isError($result)) { |
|
|
|
|
$entry = 'DB Error: "'.$result->getMessage().'"<br />'; |
|
|
|
|
$entry .= 'Offending command was: '.$result->getDebugInfo().'<br />'; |
|
|
|
|
OC_Log::write('removeStorage',$entry,OC_Log::ERROR); |
|
|
|
|
die( $entry ); |
|
|
|
|
} |
|
|
|
|
$ret = array(); |
|
|
|
|
while($row=$result->fetchRow()){ |
|
|
|
|
$ret[$row['token']] = array( |
|
|
|
|
@ -42,23 +30,11 @@ class OC_remoteStorage { |
|
|
|
|
$user=OC_User::getUser(); |
|
|
|
|
$query=OC_DB::prepare("DELETE FROM *PREFIX*authtoken WHERE token=? AND user=?"); |
|
|
|
|
$result=$query->execute(array($token,$user)); |
|
|
|
|
if( PEAR::isError($result)) { |
|
|
|
|
$entry = 'DB Error: "'.$result->getMessage().'"<br />'; |
|
|
|
|
$entry .= 'Offending command was: '.$result->getDebugInfo().'<br />'; |
|
|
|
|
OC_Log::write('removeStorage',$entry,OC_Log::ERROR); |
|
|
|
|
die( $entry ); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
private static function addToken($token, $appUrl, $userAddress, $dataScope){ |
|
|
|
|
$user=OC_User::getUser(); |
|
|
|
|
$query=OC_DB::prepare("INSERT INTO *PREFIX*authtoken (`token`,`appUrl`,`user`,`userAddress`,`dataScope`) VALUES(?,?,?,?,?)"); |
|
|
|
|
$result=$query->execute(array($token,$appUrl,$user,$userAddress,$dataScope)); |
|
|
|
|
if( PEAR::isError($result)) { |
|
|
|
|
$entry = 'DB Error: "'.$result->getMessage().'"<br />'; |
|
|
|
|
$entry .= 'Offending command was: '.$result->getDebugInfo().'<br />'; |
|
|
|
|
OC_Log::write('removeStorage',$entry,OC_Log::ERROR); |
|
|
|
|
die( $entry ); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
public static function createDataScope($appUrl, $userAddress, $dataScope){ |
|
|
|
|
$token=uniqid(); |
|
|
|
|
|