Skip to content
Snippets Groups Projects
Select Git revision
  • 315344eb9cc58dda23bfe52c1413ad963265a9cb
  • master default protected
2 results

api.php

Blame
  • log.php 4.22 KiB
    <?php
    /**
     * ownCloud
     *
     * @author Frank Karlitschek
     * @author Jakob Sack
     * @copyright 2010 Frank Karlitschek karlitschek@kde.org
     *
     * This library is free software; you can redistribute it and/or
     * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
     * License as published by the Free Software Foundation; either
     * version 3 of the License, or any later version.
     *
     * This library is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
     *
     * You should have received a copy of the GNU Affero General Public
     * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
     *
     */
    /*
     *
     * The following SQL statement is just a help for developers and will not be
     * executed!
     *
     * CREATE TABLE `log` (
     * `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
     * `moment` DATETIME NOT NULL ,
     * `appid` VARCHAR( 255 ) NOT NULL ,
     * `user` VARCHAR( 255 ) NOT NULL ,
     * `action` VARCHAR( 255 ) NOT NULL ,
     * `info` TEXT NOT NULL
     * ) ENGINE = MYISAM ;
     *
     */
    
    /**
     * This class is for logging
     */
    class OC_LOG {
    	/**
    	 * @brief adds an entry to the log
    	 * @param $appid id of the app
    	 * @param $subject username
    	 * @param $predicate action
    	 * @param $object = null; additional information
    	 * @returns true/false
    	 *
    	 * This function adds another entry to the log database
    	 */
    	public static function add( $appid, $subject, $predicate, $object = ' ' ){
    		$query=OC_DB::prepare("INSERT INTO *PREFIX*log(moment,appid,user,action,info) VALUES(NOW(),?,?,?,?)");
    		$result=$query->execute(array($appid,$subject,$predicate,$object));
    		// Die if we have an error
    		if( PEAR::isError($result)) {
    			$entry = 'DB Error: "'.$result->getMessage().'"<br />';
    			$entry .= 'Offending command was: '.$query.'<br />';
    			error_log( $entry );
    			die( $entry );
    		}
    		return true;
    	}
    
    	/**
    	 * @brief Fetches log entries
    	 * @param $filter = array(); array with filter options
    	 * @returns array with entries
    	 *