]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix some, do not enjoy php
authorMartin T. H. Sandsmark <sandsmark@samfundet.no>
Sun, 25 Jul 2010 00:38:35 +0000 (02:38 +0200)
committerMartin T. H. Sandsmark <sandsmark@samfundet.no>
Sun, 25 Jul 2010 00:38:35 +0000 (02:38 +0200)
inc/lib_base.php
inc/lib_ocs.php

index 5b80055ad8321df125aff817652ef461cbcd8dab..65387471b2bd292faaf2959c6095bd70d0605c91 100644 (file)
@@ -391,6 +391,7 @@ class OC_DB {
                if (PEAR::isError($result)) {
                        $entry='DB Error: "'.$result->getMessage().'"<br />';
                        $entry.='Offending command was: '.$cmd.'<br />';
+            error_log($entry);
                        die($entry);
                }else{
                        self::$affected=$result;
index a4d9534bb30f5c7bb17e5df95d8f0bb46175e35d..a6d128a397078fba00d8190bf6f82b42d67cd768 100644 (file)
@@ -135,15 +135,17 @@ class OC_OCS {
 
     // PRIVATEDATA
     // get - GET DATA
-    }elseif(($method=='get') and (strtolower($ex[$paracount-4])=='v1.php')and (strtolower($ex[$paracount-3])=='privatedata')){
-      $key=OC_OCS::readdata('key','text');
+    }elseif(($method=='get') and (strtolower($ex[$paracount-4])=='v1.php')and (strtolower($ex[$paracount-2])=='getattribute')){
+      OC_OCS::privateDataGet("");
+
+    }elseif(($method=='get') and (strtolower($ex[$paracount-5])=='v1.php')and (strtolower($ex[$paracount-3])=='getattribute')){
+      $key=$ex[$paracount-2];
       OC_OCS::privateDataGet($key);
 
     // set - POST DATA
-    }elseif(($method=='post') and (strtolower($ex[$paracount-4])=='v1.php')and (strtolower($ex[$paracount-3])=='privatedata')){
-      $key=OC_OCS::readdata('key','text');
+    }elseif(($method=='post') and (strtolower($ex[$paracount-5])=='v1.php')and (strtolower($ex[$paracount-3])=='setattribute')){
+      $key=$ex[$paracount-2];
       $value=OC_OCS::readdata('value','text');
-      error_log("key: '$key', value: '$value'");
       OC_OCS::privatedataset($key, $value);
 
     }else{
@@ -442,7 +444,11 @@ class OC_OCS {
 
     $user=OC_OCS::checkpassword();
 
-    $result = OC_DB::select("select key,value,timestamp from {$CONFIG_DBTABLEPREFIX}privatedata where key like'% ".addslashes($key)."%' order by timestamp desc");
+    if (!trim($key)) {
+        $result = OC_DB::select("select key,value,timestamp from {$CONFIG_DBTABLEPREFIX}privatedata order by timestamp desc");
+    } else {
+        $result = OC_DB::select("select key,value,timestamp from {$CONFIG_DBTABLEPREFIX}privatedata where key like'% ".addslashes($key)."%' order by timestamp desc");
+    }
     $itemscount=count($result);
 
     $xml=array();
@@ -453,7 +459,7 @@ class OC_OCS {
     }
 
 
-    $txt=OC_OCS::generatexml($format,'ok',100,'',$xml,'activity','full',2,$totalcount,$pagesize);
+    $txt=OC_OCS::generatexml($format,'ok',100,'',$xml,'privatedata','full',2,$totalcount,$pagesize);
     echo($txt);
   }
 
@@ -469,10 +475,10 @@ class OC_OCS {
     //TODO: prepared statements, locking tables, fancy stuff, error checking/handling
     $user=OC_OCS::checkpassword();
 
-    $result=OC_DB::query("select count(*) as co from {$CONFIG_DBTABLEPREFIX}privatedata where key = '".$key."'");
-//    $entry=$result->fetchRow();
-    //$totalcount=$entry['co'];
-    $totalcount=(integer)$result['co'];
+    $result=OC_DB::select("select count(*) as co from {$CONFIG_DBTABLEPREFIX}privatedata where key = '".$key."'");
+    $entry=$result->fetchRow();
+    $totalcount=$entry['co'];
+    //$totalcount=(integer)$result['co'];
     OC_DB::free_result($result);
     error_log($totalcount);