fixes in log and ocs

This commit is contained in:
Robin 2010-05-15 22:29:14 +02:00
parent 35711d7534
commit 78e54e1909
5 changed files with 35 additions and 21 deletions

View File

@ -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)
*

View File

@ -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')
);

View File

@ -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);
}
}

View File

@ -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'];

View File

@ -22,6 +22,7 @@
*/
require_once('../inc/lib_base.php');
ob_clean();
OC_OCS::handle();
?>