diff options
author | Robin Appelman <icewind1991@gmail.com> | 2011-10-16 21:42:24 +0200 |
---|---|---|
committer | Robin Appelman <icewind1991@gmail.com> | 2011-10-16 21:42:24 +0200 |
commit | b0127e39188f2268dbd74714e5d2f0e1a2b6ce7b (patch) | |
tree | 63b365930c0232613f28ffbd477202f857fdabee | |
parent | d9372ac76606cd10e680852dde090171f04f5dee (diff) | |
download | nextcloud-server-b0127e39188f2268dbd74714e5d2f0e1a2b6ce7b.tar.gz nextcloud-server-b0127e39188f2268dbd74714e5d2f0e1a2b6ce7b.zip |
use OC_Log instead of error_log
-rw-r--r-- | apps/admin_export/settings.php | 28 | ||||
-rw-r--r-- | apps/media/ajax/autoupdate.php | 2 | ||||
-rw-r--r-- | apps/media/lib_ampache.php | 1 | ||||
-rw-r--r-- | apps/media/lib_media.php | 2 | ||||
-rw-r--r-- | apps/media/lib_scanner.php | 8 | ||||
-rw-r--r-- | apps/media/server/xml.server.php | 2 | ||||
-rw-r--r-- | apps/remoteStorage/lib_remoteStorage.php | 8 | ||||
-rw-r--r-- | apps/user_openid/appinfo/app.php | 14 | ||||
-rw-r--r-- | apps/user_openid/phpmyid.php | 12 | ||||
-rw-r--r-- | apps/user_openid/user.php | 2 | ||||
-rw-r--r-- | files/ajax/newfolder.php | 2 | ||||
-rw-r--r-- | index.php | 6 | ||||
-rw-r--r-- | lib/db.php | 9 | ||||
-rw-r--r-- | lib/filestorage/local.php | 1 | ||||
-rw-r--r-- | lib/installer.php | 16 | ||||
-rw-r--r-- | lib/preferences.php | 1 |
16 files changed, 47 insertions, 67 deletions
diff --git a/apps/admin_export/settings.php b/apps/admin_export/settings.php index 8308a2b89b5..1685e5c0ca1 100644 --- a/apps/admin_export/settings.php +++ b/apps/admin_export/settings.php @@ -26,14 +26,14 @@ if (isset($_POST['admin_export'])) { $root = OC::$SERVERROOT . "/"; $zip = new ZipArchive(); $filename = sys_get_temp_dir() . "/owncloud_export_" . date("y-m-d_H-i-s") . ".zip"; - error_log("Creating export file at: " . $filename); + OC_Log::write('admin_export',"Creating export file at: " . $filename,OC_Log::INFO); if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) { exit("Cannot open <$filename>\n"); } if (isset($_POST['owncloud_system'])) { // adding owncloud system files - error_log("Adding owncloud system files to export"); + OC_Log::write('admin_export',"Adding owncloud system files to export",OC_Log::INFO); zipAddDir($root, $zip, false); foreach (array(".git", "3rdparty", "apps", "core", "files", "l10n", "lib", "ocs", "search", "settings", "tests") as $dirname) { zipAddDir($root . $dirname, $zip, true, basename($root) . "/"); @@ -43,7 +43,7 @@ if (isset($_POST['admin_export'])) { if (isset($_POST['owncloud_config'])) { // adding owncloud config // todo: add database export - error_log("Adding owncloud config to export"); + OC_Log::write('admin_export',"Adding owncloud config to export",OC_Log::INFO); zipAddDir($root . "config/", $zip, true, basename($root) . "/"); $zip->addFile($root . '/data/.htaccess', basename($root) . "/data/owncloud.db"); } @@ -53,7 +53,7 @@ if (isset($_POST['admin_export'])) { $zip->addFile($root . '/data/.htaccess', basename($root) . "/data/.htaccess"); $zip->addFile($root . '/data/index.html', basename($root) . "/data/index.html"); foreach (OC_User::getUsers() as $i) { - error_log("Adding owncloud user files of $i to export"); + OC_Log::write('admin_export',"Adding owncloud user files of $i to export",OC_Log::INFO); zipAddDir($root . "data/" . $i, $zip, true, basename($root) . "/data/"); } } @@ -78,19 +78,19 @@ function zipAddDir($dir, $zip, $recursive=true, $internalDir='') { $internalDir.=$dirname.='/'; if ($dirhandle = opendir($dir)) { - while (false !== ( $file = readdir($dirhandle))) { + while (false !== ( $file = readdir($dirhandle))) { - if (( $file != '.' ) && ( $file != '..' )) { + if (( $file != '.' ) && ( $file != '..' )) { - if (is_dir($dir . '/' . $file) && $recursive) { - zipAddDir($dir . '/' . $file, $zip, $recursive, $internalDir); - } elseif (is_file($dir . '/' . $file)) { - $zip->addFile($dir . '/' . $file, $internalDir . $file); + if (is_dir($dir . '/' . $file) && $recursive) { + zipAddDir($dir . '/' . $file, $zip, $recursive, $internalDir); + } elseif (is_file($dir . '/' . $file)) { + $zip->addFile($dir . '/' . $file, $internalDir . $file); + } + } } - } - } - closedir($dirhandle); + closedir($dirhandle); } else { - error_log("Was not able to open directory: " . $dir); + OC_Log::write('admin_export',"Was not able to open directory: " . $dir,OC_Log::ERROR); } } diff --git a/apps/media/ajax/autoupdate.php b/apps/media/ajax/autoupdate.php index ff0923ca032..a78b5e25dd1 100644 --- a/apps/media/ajax/autoupdate.php +++ b/apps/media/ajax/autoupdate.php @@ -30,9 +30,7 @@ $RUNTIME_NOSETUPFS=true; require_once('../../../lib/base.php'); OC_JSON::checkAppEnabled('media'); -if(defined("DEBUG") && DEBUG) {error_log($_GET['autoupdate']);} $autoUpdate=(isset($_GET['autoupdate']) and $_GET['autoupdate']=='true'); -if(defined("DEBUG") && DEBUG) {error_log((integer)$autoUpdate);} OC_Preferences::setValue(OC_User::getUser(),'media','autoupdate',(integer)$autoUpdate); diff --git a/apps/media/lib_ampache.php b/apps/media/lib_ampache.php index 87291958af3..0ad84d66809 100644 --- a/apps/media/lib_ampache.php +++ b/apps/media/lib_ampache.php @@ -195,7 +195,6 @@ class OC_MEDIA_AMPACHE{ $filter=isset($params['filter'])?$params['filter']:''; $exact=isset($params['exact'])?($params['exact']=='true'):false; $artists=OC_MEDIA_COLLECTION::getArtists($filter,$exact); - if(defined("DEBUG") && DEBUG) {error_log('artists found: '.print_r($artists,true));} echo('<root>'); foreach($artists as $artist){ self::printArtist($artist); diff --git a/apps/media/lib_media.php b/apps/media/lib_media.php index 7a666be8c27..485d616e1aa 100644 --- a/apps/media/lib_media.php +++ b/apps/media/lib_media.php @@ -40,7 +40,6 @@ class OC_MEDIA{ */ public static function loginListener($params){ if(isset($_POST['user']) and $_POST['password']){ - if(defined("DEBUG") && DEBUG) {error_log('postlogin');} $name=$_POST['user']; $query=OC_DB::prepare("SELECT user_id from *PREFIX*media_users WHERE user_id LIKE ?"); $uid=$query->execute(array($name))->fetchAll(); @@ -64,7 +63,6 @@ class OC_MEDIA{ $path=substr($path,1); } $path='/'.$path; - error_log("$path was updated"); OC_MEDIA_SCANNER::scanFile($path); } diff --git a/apps/media/lib_scanner.php b/apps/media/lib_scanner.php index 9bf9397b19a..ef63cea45df 100644 --- a/apps/media/lib_scanner.php +++ b/apps/media/lib_scanner.php @@ -97,25 +97,25 @@ class OC_MEDIA_SCANNER{ $data=@self::$getID3->analyze($file); getid3_lib::CopyTagsToComments($data); if(!isset($data['comments'])){ - if(defined("DEBUG") && DEBUG) {error_log("error reading id3 tags in '$file'");} + OC_Log::write('media',"error reading id3 tags in '$file'",OC_Log::WARN); return; } if(!isset($data['comments']['artist'])){ - if(defined("DEBUG") && DEBUG) {error_log("error reading artist tag in '$file'");} + OC_Log::write('media',"error reading artist tag in '$file'",OC_Log::WARN); $artist='unknown'; }else{ $artist=stripslashes($data['comments']['artist'][0]); $artist=utf8_encode($artist); } if(!isset($data['comments']['album'])){ - if(defined("DEBUG") && DEBUG) {error_log("error reading album tag in '$file'");} + OC_Log::write('media',"error reading album tag in '$file'",OC_Log::WARN); $album='unknown'; }else{ $album=stripslashes($data['comments']['album'][0]); $album=utf8_encode($album); } if(!isset($data['comments']['title'])){ - if(defined("DEBUG") && DEBUG) {error_log("error reading title tag in '$file'");} + OC_Log::write('media',"error reading title tag in '$file'",OC_Log::WARN); $title='unknown'; }else{ $title=stripslashes($data['comments']['title'][0]); diff --git a/apps/media/server/xml.server.php b/apps/media/server/xml.server.php index 44a16793bf2..2d54c863c79 100644 --- a/apps/media/server/xml.server.php +++ b/apps/media/server/xml.server.php @@ -37,7 +37,7 @@ foreach($arguments as &$argument){ } ob_clean(); if(isset($arguments['action'])){ - if(defined("DEBUG") && DEBUG) {error_log($arguments['action']);} + OC_Log::write('media','ampache '.$arguments['action'].' request', OC_Log::DEBUG); switch($arguments['action']){ case 'url_to_song': OC_MEDIA_AMPACHE::url_to_song($arguments); diff --git a/apps/remoteStorage/lib_remoteStorage.php b/apps/remoteStorage/lib_remoteStorage.php index 5677ab3c6e0..f10a72870a4 100644 --- a/apps/remoteStorage/lib_remoteStorage.php +++ b/apps/remoteStorage/lib_remoteStorage.php @@ -7,7 +7,7 @@ class OC_remoteStorage { if( PEAR::isError($result)) { $entry = 'DB Error: "'.$result->getMessage().'"<br />'; $entry .= 'Offending command was: '.$result->getDebugInfo().'<br />'; - if(defined("DEBUG") && DEBUG) {error_log( $entry );} + OC_Log::write('removeStorage',$entry,OC_Log::ERROR); die( $entry ); } $ret = array(); @@ -24,7 +24,7 @@ class OC_remoteStorage { if( PEAR::isError($result)) { $entry = 'DB Error: "'.$result->getMessage().'"<br />'; $entry .= 'Offending command was: '.$result->getDebugInfo().'<br />'; - if(defined("DEBUG") && DEBUG) {error_log( $entry );} + OC_Log::write('removeStorage',$entry,OC_Log::ERROR); die( $entry ); } $ret = array(); @@ -45,7 +45,7 @@ class OC_remoteStorage { if( PEAR::isError($result)) { $entry = 'DB Error: "'.$result->getMessage().'"<br />'; $entry .= 'Offending command was: '.$result->getDebugInfo().'<br />'; - if(defined("DEBUG") && DEBUG) {error_log( $entry );} + OC_Log::write('removeStorage',$entry,OC_Log::ERROR); die( $entry ); } } @@ -56,7 +56,7 @@ class OC_remoteStorage { if( PEAR::isError($result)) { $entry = 'DB Error: "'.$result->getMessage().'"<br />'; $entry .= 'Offending command was: '.$result->getDebugInfo().'<br />'; - if(defined("DEBUG") && DEBUG) {error_log( $entry );} + OC_Log::write('removeStorage',$entry,OC_Log::ERROR); die( $entry ); } } diff --git a/apps/user_openid/appinfo/app.php b/apps/user_openid/appinfo/app.php index 546f9f4565a..912019a9700 100644 --- a/apps/user_openid/appinfo/app.php +++ b/apps/user_openid/appinfo/app.php @@ -26,14 +26,14 @@ OC_User::useBackend('openid'); //check for results from openid requests if(isset($_GET['openid_mode']) and $_GET['openid_mode'] == 'id_res'){ - if(defined("DEBUG") && DEBUG) {error_log('openid retured');} + OC_Log::write('user_openid','openid retured',OC_Log::DEBUG); $openid = new SimpleOpenID; $openid->SetIdentity($_GET['openid_identity']); $openid_validation_result = $openid->ValidateWithServer(); if ($openid_validation_result == true){ // OK HERE KEY IS VALID - if(defined("DEBUG") && DEBUG) {error_log('auth sucessfull');} + OC_Log::write('user_openid','auth sucessfull',OC_Log::DEBUG); $identity=$openid->GetIdentity(); - if(defined("DEBUG") && DEBUG) {error_log("auth as $identity");} + OC_Log::write('user_openid','auth as '.$identity,OC_Log::DEBUG); $user=OC_USER_OPENID::findUserForIdentity($identity); if($user){ $_SESSION['user_id']=$user; @@ -41,13 +41,13 @@ if(isset($_GET['openid_mode']) and $_GET['openid_mode'] == 'id_res'){ } }else if($openid->IsError() == true){ // ON THE WAY, WE GOT SOME ERROR $error = $openid->GetError(); - if(defined("DEBUG") && DEBUG) {error_log("ERROR CODE: " . $error['code']);} - if(defined("DEBUG") && DEBUG) {error_log("ERROR DESCRIPTION: " . $error['description']);} + OC_Log::write('user_openid','ERROR CODE: '. $error['code'],OC_Log::ERROR); + OC_Log::write('user_openid','ERROR DESCRIPTION: '. $error['description'],OC_Log::ERROR); }else{ // Signature Verification Failed - if(defined("DEBUG") && DEBUG) {error_log("INVALID AUTHORIZATION");} + OC_Log::write('user_openid','INVALID AUTHORIZATION',OC_Log::ERROR); } }else if (isset($_GET['openid_mode']) and $_GET['openid_mode'] == 'cancel'){ // User Canceled your Request - if(defined("DEBUG") && DEBUG) {error_log("USER CANCELED REQUEST");} + OC_Log::write('user_openid','USER CANCELED REQUEST',OC_Log::DEBUG); return false; } diff --git a/apps/user_openid/phpmyid.php b/apps/user_openid/phpmyid.php index 5009fa410aa..d8168c9a10d 100644 --- a/apps/user_openid/phpmyid.php +++ b/apps/user_openid/phpmyid.php @@ -1053,8 +1053,6 @@ function debug ($x, $m = null) { } else { $x .= "\n"; } - - if(defined("DEBUG") && DEBUG) {error_log($x . "\n", 3, $profile['logfile']);} } @@ -1513,7 +1511,6 @@ function wrap_html ( $message ) { </body> </html> '; - if(defined("DEBUG") && DEBUG) {error_log($html);} echo $html; exit(0); } @@ -1658,15 +1655,6 @@ $profile['req_url'] = sprintf("%s://%s%s", // $port,//host already includes the path $_SERVER["REQUEST_URI"]); -// $fullId='user.php/'.$USERNAME.'/'; -// $incompleteId='user.php/'; - -// if(!strpos($profile['req_url'],$fullId)){ -// $profile['req_url']=str_replace($incompleteId,$fullId,$profile['req_url']); -// } - -// if(defined("DEBUG") && DEBUG) {error_log('inc id: '.$fullId);} -// if(defined("DEBUG") && DEBUG) {error_log('req url: '.$profile['req_url']);} // Set the default allowance for testing if (! array_key_exists('allow_test', $profile)) diff --git a/apps/user_openid/user.php b/apps/user_openid/user.php index 3cbc38491ca..a267e020507 100644 --- a/apps/user_openid/user.php +++ b/apps/user_openid/user.php @@ -40,7 +40,7 @@ require_once '../../lib/base.php'; OC_Util::checkAppEnabled('user_openid'); if(!OC_User::userExists($USERNAME)){ - if(defined("DEBUG") && DEBUG) {error_log($USERNAME.' doesn\'t exist');} + OC_Log::write('user_openid',$USERNAME.' doesn\'t exist',OC_Log::WARN); $USERNAME=''; } $IDENTITY=OC_Helper::linkTo( "user_openid", "user.php", null, true ).'/'.$USERNAME; diff --git a/files/ajax/newfolder.php b/files/ajax/newfolder.php index 43d87461fc7..6966e912c56 100644 --- a/files/ajax/newfolder.php +++ b/files/ajax/newfolder.php @@ -13,7 +13,7 @@ if($foldername == '') { OC_JSON::error(array("data" => array( "message" => "Empty Foldername" ))); exit(); } -if(defined("DEBUG") && DEBUG) {error_log('try to create ' . $foldername . ' in ' . $dir);} + if(OC_Files::newFile($dir, $foldername, 'dir')) { OC_JSON::success(array("data" => array())); exit(); diff --git a/index.php b/index.php index 924e7394f7b..558733e1cda 100644 --- a/index.php +++ b/index.php @@ -31,7 +31,7 @@ if($not_installed) { // Check for autosetup: $autosetup_file = OC::$SERVERROOT."/config/autoconfig.php"; if( file_exists( $autosetup_file )){ - error_log("Autoconfig file found, setting up owncloud..."); + OC_Log::write('core','Autoconfig file found, setting up owncloud...',OC_Log::INFO); include( $autosetup_file ); $_POST['install'] = 'true'; $_POST = array_merge ($_POST, $AUTOCONFIG); @@ -68,7 +68,7 @@ else { // remember was checked after last login if(isset($_COOKIE["oc_remember_login"]) && isset($_COOKIE["oc_token"]) && isset($_COOKIE["oc_username"]) && $_COOKIE["oc_remember_login"]) { if(defined("DEBUG") && DEBUG) { - error_log("Trying to login from cookie"); + OC_Log::write('core','Trying to login from cookie',OC_Log::DEBUG); } // confirm credentials in cookie if(isset($_COOKIE['oc_token']) && OC_User::userExists($_COOKIE['oc_username']) && @@ -86,7 +86,7 @@ else { if(OC_User::login($_POST["user"], $_POST["password"])) { if(!empty($_POST["remember_login"])){ if(defined("DEBUG") && DEBUG) { - error_log("Setting remember login to cookie"); + OC_Log::write('core','Setting remember login to cookie',OC_Log::DEBUG); } $token = md5($_POST["user"].time()); OC_Preferences::setValue($_POST['user'], 'login', 'token', $token); diff --git a/lib/db.php b/lib/db.php index ef6d1dcc8b7..fa3995be125 100644 --- a/lib/db.php +++ b/lib/db.php @@ -161,9 +161,8 @@ class OC_DB { // Die if we could not connect if( PEAR::isError( self::$MDB2 )){ echo( '<b>can not connect to database, using '.$type.'. ('.self::$MDB2->getUserInfo().')</center>'); - $error = self::$MDB2->getMessage(); - error_log( $error); - error_log( self::$MDB2->getUserInfo()); + OC_Log::write('core',self::$MDB2->getUserInfo(),OC_Log::FATAL); + OC_Log::write('core',self::$MDB2->getMessage(),OC_Log::FATAL); die( $error ); } @@ -195,7 +194,7 @@ class OC_DB { if( PEAR::isError($result)) { $entry = 'DB Error: "'.$result->getMessage().'"<br />'; $entry .= 'Offending command was: '.$query.'<br />'; - error_log( $entry ); + OC_Log::write('core',$entry,OC_Log::FATAL); die( $entry ); } }else{ @@ -204,7 +203,7 @@ class OC_DB { }catch(PDOException $e){ $entry = 'DB Error: "'.$e->getMessage().'"<br />'; $entry .= 'Offending command was: '.$query.'<br />'; - error_log( $entry ); + OC_Log::write('core',$entry,OC_Log::FATAL); die( $entry ); } $result=new PDOStatementWrapper($result); diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php index 180b056f344..8e0907f8d3b 100644 --- a/lib/filestorage/local.php +++ b/lib/filestorage/local.php @@ -195,7 +195,6 @@ class OC_Filestorage_Local extends OC_Filestorage{ } private function delTree($dir) { - if(defined("DEBUG") && DEBUG) {error_log('del'.$dir);} $dirRelative=$dir; $dir=$this->datadir.$dir; if (!file_exists($dir)) return true; diff --git a/lib/installer.php b/lib/installer.php index 0febb2cab46..242ca97934f 100644 --- a/lib/installer.php +++ b/lib/installer.php @@ -56,7 +56,7 @@ class OC_Installer{ */ public static function installApp( $data = array()){ if(!isset($data['source'])){ - if(defined("DEBUG") && DEBUG) {error_log("No source specified when installing app");} + OC_Log::write('core','No source specified when installing app',OC_Log::ERROR); return false; } @@ -64,13 +64,13 @@ class OC_Installer{ if($data['source']=='http'){ $path=tempnam(sys_get_temp_dir(),'oc_installer_'); if(!isset($data['href'])){ - if(defined("DEBUG") && DEBUG) {error_log("No href specified when installing app from http");} + OC_Log::write('core','No href specified when installing app from http',OC_Log::ERROR); return false; } copy($data['href'],$path); }else{ if(!isset($data['path'])){ - if(defined("DEBUG") && DEBUG) {error_log("No path specified when installing app from local file");} + OC_Log::write('core','No path specified when installing app from local file',OC_Log::ERROR); return false; } $path=$data['path']; @@ -85,7 +85,7 @@ class OC_Installer{ $zip->extractTo($extractDir); $zip->close(); } else { - if(defined("DEBUG") && DEBUG) {error_log("Failed to open archive when installing app");} + OC_Log::write('core','Failed to open archive when installing app',OC_Log::ERROR); OC_Helper::rmdirr($extractDir); if($data['source']=='http'){ unlink($path); @@ -95,7 +95,7 @@ class OC_Installer{ //load the info.xml file of the app if(!is_file($extractDir.'/appinfo/info.xml')){ - if(defined("DEBUG") && DEBUG) {error_log("App does not provide an info.xml file");} + OC_Log::write('core','App does not provide an info.xml file',OC_Log::ERROR); OC_Helper::rmdirr($extractDir); if($data['source']=='http'){ unlink($path); @@ -107,7 +107,7 @@ class OC_Installer{ //check if an app with the same id is already installed if(self::isInstalled( $info['id'] )){ - if(defined("DEBUG") && DEBUG) {error_log("App already installed");} + OC_Log::write('core','App already installed',OC_Log::WARN); OC_Helper::rmdirr($extractDir); if($data['source']=='http'){ unlink($path); @@ -117,7 +117,7 @@ class OC_Installer{ //check if the destination directory already exists if(is_dir($basedir)){ - if(defined("DEBUG") && DEBUG) {error_log("App's directory already exists");} + OC_Log::write('core','App directory already exists',OC_Log::WARN); OC_Helper::rmdirr($extractDir); if($data['source']=='http'){ unlink($path); @@ -131,7 +131,7 @@ class OC_Installer{ //copy the app to the correct place if(!mkdir($basedir)){ - if(defined("DEBUG") && DEBUG) {error_log('Can\'t create app folder ('.$basedir.')');} + OC_Log::write('core','Can\'t create app folder ('.$basedir.')',OC_Log::ERROR); OC_Helper::rmdirr($extractDir); if($data['source']=='http'){ unlink($path); diff --git a/lib/preferences.php b/lib/preferences.php index 6d8aa17afd5..75201f455ba 100644 --- a/lib/preferences.php +++ b/lib/preferences.php @@ -140,7 +140,6 @@ class OC_Preferences{ // Check if the key does exist $query = OC_DB::prepare( 'SELECT configvalue FROM *PREFIX*preferences WHERE userid = ? AND appid = ? AND configkey = ?' ); $values=$query->execute(array($user,$app,$key))->fetchAll(); - if(defined("DEBUG") && DEBUG) {error_log(print_r($values,true));} $exists=(count($values)>0); if( !$exists ){ |