summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xinc/lib_base.php25
-rwxr-xr-xinc/lib_config.php4
-rwxr-xr-xinc/lib_log.php9
-rwxr-xr-xinc/lib_ocs.php17
-rwxr-xr-xocs/v1.php1
5 files changed, 35 insertions, 21 deletions
diff --git a/inc/lib_base.php b/inc/lib_base.php
index 6eef3affd40..303809bdd6b 100755
--- a/inc/lib_base.php
+++ b/inc/lib_base.php
@@ -423,7 +423,6 @@ class OC_DB {
static function numrows($result) {
$result->numRows();
}
-
/**
* Returning number of affected rows
*
@@ -433,6 +432,30 @@ class OC_DB {
self::$DBConnection->affectedRows();
}
+ /**
+ * get a field from the resultset
+ *
+ * @param resultset $result
+ * @param int $i
+ * @param int $field
+ * @return unknown
+ */
+ static function result($result, $i, $field) {
+ $tmp=$result->fetchRow(MDB2_FETCHMODE_ASSOC,$i);
+ $tmp=$tmp[$field];
+ return($tmp);
+ }
+
+ /**
+ * get data-array from resultset
+ *
+ * @param resultset $result
+ * @return data
+ */
+ static function fetch_assoc($result){
+ return $result->fetchRow(MDB2_FETCHMODE_ASSOC);
+ }
+
/**
* Freeing resultset (performance)
*
diff --git a/inc/lib_config.php b/inc/lib_config.php
index a6567bc8293..986d12f4dce 100755
--- a/inc/lib_config.php
+++ b/inc/lib_config.php
@@ -292,10 +292,12 @@ class OC_CONFIG{
);
CREATE TABLE 'log' (
+ `id` INTEGER ASC DEFAULT '' NOT NULL,
'timestamp' int(11) NOT NULL,
'user' varchar(250) NOT NULL,
'type' int(11) NOT NULL,
- 'message' varchar(250) NOT NULL
+ 'message' varchar(250) NOT NULL,
+ PRIMARY KEY ('id')
);
diff --git a/inc/lib_log.php b/inc/lib_log.php
index 2a8a91be40a..5e47c4ee162 100755
--- a/inc/lib_log.php
+++ b/inc/lib_log.php
@@ -61,11 +61,8 @@ class OC_LOG {
global $CONFIG_DATEFORMAT;
echo('<div class="center"><table cellpadding="6" cellspacing="0" border="0" class="log">');
- $result = OC_DB::query('select timestamp,user,type,message from log order by timestamp desc limit 20');
- $count=OC_DB::numrows($result);
- for ($i=0; $i < $count;$i++) {
-
- $entry=OC_DB::fetch_assoc($result);
+ $result = OC_DB::select('select timestamp,user,type,message from log order by timestamp desc limit 20');
+ foreach($result as $entry){
echo('<tr class="browserline">');
echo('<td class="sizetext">'.date($CONFIG_DATEFORMAT,$entry['timestamp']).'</td>');
echo('<td class="highlighttext">'.OC_LOG::$TYPE[$entry['type']].'</td>');
@@ -74,8 +71,6 @@ class OC_LOG {
echo('</tr>');
}
echo('</table></div>');
- OC_DB::free_result($result);
-
}
}
diff --git a/inc/lib_ocs.php b/inc/lib_ocs.php
index 97c412c419a..b36c4937e07 100755
--- a/inc/lib_ocs.php
+++ b/inc/lib_ocs.php
@@ -166,9 +166,6 @@ class OC_OCS {
* @return username string
*/
private static function checkpassword($forceuser=true) {
- global $CONFIG_ADMINLOGIN;
- global $CONFIG_ADMINPASSWORD;
-
//valid user account ?
if(isset($_SERVER['PHP_AUTH_USER'])) $authuser=$_SERVER['PHP_AUTH_USER']; else $authuser='';
if(isset($_SERVER['PHP_AUTH_PW'])) $authpw=$_SERVER['PHP_AUTH_PW']; else $authpw='';
@@ -182,7 +179,7 @@ class OC_OCS {
$identifieduser='';
}
}else{
- if(($authuser<>$CONFIG_ADMINLOGIN) or ($authpw<>$CONFIG_ADMINPASSWORD)) {
+ if(!OC_USER::login($authuser,$authpw)){
if($forceuser){
header('WWW-Authenticate: Basic realm="your valid user account or api key"');
header('HTTP/1.0 401 Unauthorized');
@@ -351,11 +348,8 @@ class OC_OCS {
* @return string xml/json
*/
private static function personcheck($format,$login,$passwd) {
- global $CONFIG_ADMINLOGIN;
- global $CONFIG_ADMINPASSWORD;
-
if($login<>''){
- if(($login==$CONFIG_ADMINLOGIN) and ($passwd==$CONFIG_ADMINPASSWORD)) {
+ if(OC_USER::login($login,$passwd)){
$xml['person']['personid']=$login;
echo(OC_OCS::generatexml($format,'ok',100,'',$xml,'person','check',2));
}else{
@@ -386,13 +380,12 @@ class OC_OCS {
$totalcount=$entry['co'];
OC_DB::free_result($result);
- $result = OC_DB::query('select id,timestamp,user,type,message from log order by timestamp desc limit '.($page*$pagesize).','.$pagesize);
- $itemscount=OC_DB::numrows($result);
+ $result = OC_DB::select('select id,timestamp,user,type,message from log order by timestamp desc limit '.($page*$pagesize).','.$pagesize);
+ $itemscount=count($result);
$url='http://'.substr($_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'],0,-11).'';
$xml=array();
- for ($i=0; $i < $itemscount;$i++) {
- $log=OC_DB::fetch_assoc($result);
+ foreach($result as $i=>$log) {
$xml[$i]['id']=$log['id'];
$xml[$i]['personid']=$log['user'];
$xml[$i]['firstname']=$log['user'];
diff --git a/ocs/v1.php b/ocs/v1.php
index 14d56bbec60..2419658ff10 100755
--- a/ocs/v1.php
+++ b/ocs/v1.php
@@ -22,6 +22,7 @@
*/
require_once('../inc/lib_base.php');
+ob_clean();
OC_OCS::handle();
?>