From 8648e3c43c26da898c17798f89d60c9505d149b3 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Thu, 22 Sep 2011 19:24:32 +0200 Subject: [PATCH] only call error_log() if DEBUG is true Signed-off-by: Florian Pritz --- 3rdparty/XML/RPC.php | 4 ++-- apps/files_publiclink/lib_public.php | 2 +- apps/media/ajax/autoupdate.php | 4 ++-- apps/media/lib_ampache.php | 2 +- apps/media/lib_media.php | 2 +- apps/media/lib_scanner.php | 8 ++++---- apps/media/server/xml.server.php | 2 +- apps/unhosted/lib_unhosted.php | 8 ++++---- apps/user_openid/appinfo/app.php | 14 +++++++------- apps/user_openid/phpmyid.php | 8 ++++---- apps/user_openid/user.php | 2 +- config/config.sample.php | 2 ++ files/ajax/newfolder.php | 2 +- index.php | 4 ++-- lib/db.php | 8 ++++---- lib/filestorage/local.php | 2 +- lib/filesystem.php | 6 +++--- lib/installer.php | 16 ++++++++-------- lib/preferences.php | 2 +- 19 files changed, 50 insertions(+), 48 deletions(-) diff --git a/3rdparty/XML/RPC.php b/3rdparty/XML/RPC.php index 2cdb44f4aea..096b22a0ab5 100644 --- a/3rdparty/XML/RPC.php +++ b/3rdparty/XML/RPC.php @@ -1365,7 +1365,7 @@ class XML_RPC_Message extends XML_RPC_Base !preg_match('@^HTTP/[0-9\.]+ 10[0-9]([A-Za-z ]+)?[\r\n]+HTTP/[0-9\.]+ 200@', $data)) { $errstr = substr($data, 0, strpos($data, "\n") - 1); - error_log('HTTP error, got response: ' . $errstr); + if(defined("DEBUG") && DEBUG) {error_log('HTTP error, got response: ' . $errstr);} $r = new XML_RPC_Response(0, $XML_RPC_err['http_error'], $XML_RPC_str['http_error'] . ' (' . $errstr . ')'); @@ -1396,7 +1396,7 @@ class XML_RPC_Message extends XML_RPC_Base xml_error_string(xml_get_error_code($parser_resource)), xml_get_current_line_number($parser_resource)); } - error_log($errstr); + if(defined("DEBUG") && DEBUG) {error_log($errstr);} $r = new XML_RPC_Response(0, $XML_RPC_err['invalid_return'], $XML_RPC_str['invalid_return']); xml_parser_free($parser_resource); diff --git a/apps/files_publiclink/lib_public.php b/apps/files_publiclink/lib_public.php index ece0a540d39..f895615380d 100644 --- a/apps/files_publiclink/lib_public.php +++ b/apps/files_publiclink/lib_public.php @@ -14,7 +14,7 @@ class OC_PublicLink{ if( PEAR::isError($result)) { $entry = 'DB Error: "'.$result->getMessage().'"
'; $entry .= 'Offending command was: '.$result->getDebugInfo().'
'; - error_log( $entry ); + if(defined("DEBUG") && DEBUG) {error_log( $entry );} die( $entry ); } $this->token=$token; diff --git a/apps/media/ajax/autoupdate.php b/apps/media/ajax/autoupdate.php index ded1fd02bc3..ac3d0650b4b 100644 --- a/apps/media/ajax/autoupdate.php +++ b/apps/media/ajax/autoupdate.php @@ -29,9 +29,9 @@ $RUNTIME_NOSETUPFS=true; require_once('../../../lib/base.php'); -error_log($_GET['autoupdate']); +if(defined("DEBUG") && DEBUG) {error_log($_GET['autoupdate']);} $autoUpdate=(isset($_GET['autoupdate']) and $_GET['autoupdate']=='true'); -error_log((integer)$autoUpdate); +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 dc88e35a697..87291958af3 100644 --- a/apps/media/lib_ampache.php +++ b/apps/media/lib_ampache.php @@ -195,7 +195,7 @@ 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); - error_log('artists found: '.print_r($artists,true)); + if(defined("DEBUG") && DEBUG) {error_log('artists found: '.print_r($artists,true));} echo(''); foreach($artists as $artist){ self::printArtist($artist); diff --git a/apps/media/lib_media.php b/apps/media/lib_media.php index 3086f84a93a..1d8321a774c 100644 --- a/apps/media/lib_media.php +++ b/apps/media/lib_media.php @@ -37,7 +37,7 @@ class OC_MEDIA{ */ public static function loginListener($params){ if(isset($_POST['user']) and $_POST['password']){ - error_log('postlogin'); + 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(); diff --git a/apps/media/lib_scanner.php b/apps/media/lib_scanner.php index c774c3c9fdb..9bf9397b19a 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'])){ - error_log("error reading id3 tags in '$file'"); + if(defined("DEBUG") && DEBUG) {error_log("error reading id3 tags in '$file'");} return; } if(!isset($data['comments']['artist'])){ - error_log("error reading artist tag in '$file'"); + if(defined("DEBUG") && DEBUG) {error_log("error reading artist tag in '$file'");} $artist='unknown'; }else{ $artist=stripslashes($data['comments']['artist'][0]); $artist=utf8_encode($artist); } if(!isset($data['comments']['album'])){ - error_log("error reading album tag in '$file'"); + if(defined("DEBUG") && DEBUG) {error_log("error reading album tag in '$file'");} $album='unknown'; }else{ $album=stripslashes($data['comments']['album'][0]); $album=utf8_encode($album); } if(!isset($data['comments']['title'])){ - error_log("error reading title tag in '$file'"); + if(defined("DEBUG") && DEBUG) {error_log("error reading title tag in '$file'");} $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 e61fadf234c..387c3480047 100644 --- a/apps/media/server/xml.server.php +++ b/apps/media/server/xml.server.php @@ -36,7 +36,7 @@ foreach($arguments as &$argument){ } ob_clean(); if(isset($arguments['action'])){ - error_log($arguments['action']); + if(defined("DEBUG") && DEBUG) {error_log($arguments['action']);} switch($arguments['action']){ case 'url_to_song': OC_MEDIA_AMPACHE::url_to_song($arguments); diff --git a/apps/unhosted/lib_unhosted.php b/apps/unhosted/lib_unhosted.php index 59dc380c45c..484f469f0ed 100644 --- a/apps/unhosted/lib_unhosted.php +++ b/apps/unhosted/lib_unhosted.php @@ -7,7 +7,7 @@ class OC_UnhostedWeb { if( PEAR::isError($result)) { $entry = 'DB Error: "'.$result->getMessage().'"
'; $entry .= 'Offending command was: '.$result->getDebugInfo().'
'; - error_log( $entry ); + if(defined("DEBUG") && DEBUG) {error_log( $entry );} die( $entry ); } $ret = array(); @@ -24,7 +24,7 @@ class OC_UnhostedWeb { if( PEAR::isError($result)) { $entry = 'DB Error: "'.$result->getMessage().'"
'; $entry .= 'Offending command was: '.$result->getDebugInfo().'
'; - error_log( $entry ); + if(defined("DEBUG") && DEBUG) {error_log( $entry );} die( $entry ); } $ret = array(); @@ -45,7 +45,7 @@ class OC_UnhostedWeb { if( PEAR::isError($result)) { $entry = 'DB Error: "'.$result->getMessage().'"
'; $entry .= 'Offending command was: '.$result->getDebugInfo().'
'; - error_log( $entry ); + if(defined("DEBUG") && DEBUG) {error_log( $entry );} die( $entry ); } } @@ -56,7 +56,7 @@ class OC_UnhostedWeb { if( PEAR::isError($result)) { $entry = 'DB Error: "'.$result->getMessage().'"
'; $entry .= 'Offending command was: '.$result->getDebugInfo().'
'; - error_log( $entry ); + if(defined("DEBUG") && DEBUG) {error_log( $entry );} die( $entry ); } } diff --git a/apps/user_openid/appinfo/app.php b/apps/user_openid/appinfo/app.php index 578f8f4dade..546f9f4565a 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'){ - error_log('openid retured'); + if(defined("DEBUG") && DEBUG) {error_log('openid retured');} $openid = new SimpleOpenID; $openid->SetIdentity($_GET['openid_identity']); $openid_validation_result = $openid->ValidateWithServer(); if ($openid_validation_result == true){ // OK HERE KEY IS VALID - error_log('auth sucessfull'); + if(defined("DEBUG") && DEBUG) {error_log('auth sucessfull');} $identity=$openid->GetIdentity(); - error_log("auth as $identity"); + if(defined("DEBUG") && DEBUG) {error_log("auth as $identity");} $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(); - error_log("ERROR CODE: " . $error['code']); - error_log("ERROR DESCRIPTION: " . $error['description']); + if(defined("DEBUG") && DEBUG) {error_log("ERROR CODE: " . $error['code']);} + if(defined("DEBUG") && DEBUG) {error_log("ERROR DESCRIPTION: " . $error['description']);} }else{ // Signature Verification Failed - error_log("INVALID AUTHORIZATION"); + if(defined("DEBUG") && DEBUG) {error_log("INVALID AUTHORIZATION");} } }else if (isset($_GET['openid_mode']) and $_GET['openid_mode'] == 'cancel'){ // User Canceled your Request - error_log("USER CANCELED REQUEST"); + if(defined("DEBUG") && DEBUG) {error_log("USER CANCELED REQUEST");} return false; } diff --git a/apps/user_openid/phpmyid.php b/apps/user_openid/phpmyid.php index 24fab44ca7a..09538b61ab1 100644 --- a/apps/user_openid/phpmyid.php +++ b/apps/user_openid/phpmyid.php @@ -1054,7 +1054,7 @@ function debug ($x, $m = null) { $x .= "\n"; } - error_log($x . "\n", 3, $profile['logfile']); + if(defined("DEBUG") && DEBUG) {error_log($x . "\n", 3, $profile['logfile']);} } @@ -1501,7 +1501,7 @@ function wrap_html ( $message ) { '; - error_log($html); + if(defined("DEBUG") && DEBUG) {error_log($html);} echo $html; exit(0); } @@ -1653,8 +1653,8 @@ $profile['req_url'] = sprintf("%s://%s%s", // $profile['req_url']=str_replace($incompleteId,$fullId,$profile['req_url']); // } -// error_log('inc id: '.$fullId); -// error_log('req url: '.$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 60e12ed88e0..d90e0b71900 100644 --- a/apps/user_openid/user.php +++ b/apps/user_openid/user.php @@ -39,7 +39,7 @@ $RUNTIME_NOAPPS=false; require_once '../../lib/base.php'; if(!OC_User::userExists($USERNAME)){ - error_log($USERNAME.' doesn\'t exist'); + if(defined("DEBUG") && DEBUG) {error_log($USERNAME.' doesn\'t exist');} $USERNAME=''; } $IDENTITY=OC_Helper::linkTo( "user_openid", "user.php", null, true ).'/'.$USERNAME; diff --git a/config/config.sample.php b/config/config.sample.php index 5575340bc1b..a40ce073bf6 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -1,5 +1,7 @@ false, "dbtype" => "sqlite", diff --git a/files/ajax/newfolder.php b/files/ajax/newfolder.php index 610418583bd..8eb05280e73 100644 --- a/files/ajax/newfolder.php +++ b/files/ajax/newfolder.php @@ -20,7 +20,7 @@ if($foldername == '') { echo json_encode( array( "status" => "error", "data" => array( "message" => "Empty Foldername" ))); exit(); } -error_log('try to create ' . $foldername . ' in ' . $dir); +if(defined("DEBUG") && DEBUG) {error_log('try to create ' . $foldername . ' in ' . $dir);} if(OC_Files::newFile($dir, $foldername, 'dir')) { echo json_encode( array( "status" => "success", "data" => array())); exit(); diff --git a/index.php b/index.php index 23bc4fb7764..26e90ddfa5c 100644 --- a/index.php +++ b/index.php @@ -55,7 +55,7 @@ elseif(OC_User::isLoggedIn()) { // remember was checked after last login elseif(isset($_COOKIE["oc_remember_login"]) && $_COOKIE["oc_remember_login"]) { OC_App::loadApps(); - error_log("Trying to login from cookie"); + if(defined("DEBUG") && DEBUG) {error_log("Trying to login from cookie");} // confirm credentials in cookie if(OC_User::userExists($_COOKIE['oc_username']) && OC_Preferences::getValue($_COOKIE['oc_username'], "login", "token") == $_COOKIE['oc_token']) { @@ -72,7 +72,7 @@ elseif(isset($_POST["user"]) && isset($_POST['password'])) { OC_App::loadApps(); if(OC_User::login($_POST["user"], $_POST["password"])) { if(!empty($_POST["remember_login"])){ - error_log("Setting remember login to cookie"); + if(defined("DEBUG") && DEBUG) {error_log("Setting remember login to cookie");} $token = md5($_POST["user"].time()); OC_Preferences::setValue($_POST['user'], 'login', 'token', $token); OC_User::setMagicInCookie($_POST["user"], $token); diff --git a/lib/db.php b/lib/db.php index 0b7065eec8b..ede8ba897e9 100644 --- a/lib/db.php +++ b/lib/db.php @@ -92,8 +92,8 @@ class OC_DB { if( PEAR::isError( self::$DBConnection )){ echo( 'can not connect to database, using '.$CONFIG_DBTYPE.'. ('.self::$DBConnection->getUserInfo().')'); $error = self::$DBConnection->getMessage(); - error_log( $error); - error_log( self::$DBConnection->getUserInfo()); + if(defined("DEBUG") && DEBUG) {error_log( $error);} + if(defined("DEBUG") && DEBUG) {error_log( self::$DBConnection->getUserInfo());} die( $error ); } @@ -129,7 +129,7 @@ class OC_DB { if( PEAR::isError($result)) { $entry = 'DB Error: "'.$result->getMessage().'"
'; $entry .= 'Offending command was: '.$query.'
'; - error_log( $entry ); + if(defined("DEBUG") && DEBUG) {error_log( $entry );} die( $entry ); } @@ -155,7 +155,7 @@ class OC_DB { if( PEAR::isError($result)) { $entry = 'DB Error: "'.$result->getMessage().'"
'; $entry .= 'Offending command was: '.$query.'
'; - error_log( $entry ); + if(defined("DEBUG") && DEBUG) {error_log( $entry );} die( $entry ); } diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php index 07759b0e88c..180b056f344 100644 --- a/lib/filestorage/local.php +++ b/lib/filestorage/local.php @@ -195,7 +195,7 @@ class OC_Filestorage_Local extends OC_Filestorage{ } private function delTree($dir) { - error_log('del'.$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/filesystem.php b/lib/filesystem.php index 76032fae204..f242a1b158e 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -286,7 +286,7 @@ class OC_Filesystem{ return self::basicOperation('file_get_contents',$path,array('read')); } static public function file_put_contents($path,$data){ - error_log($data); + if(defined("DEBUG") && DEBUG) {error_log($data);} return self::basicOperation('file_put_contents',$path,array('create','write'),$data); } static public function unlink($path){ @@ -393,7 +393,7 @@ class OC_Filesystem{ } } static public function fromUploadedFile($tmpFile,$path){ - error_log('upload'); + if(defined("DEBUG") && DEBUG) {error_log('upload');} if(OC_FileProxy::runPreProxies('fromUploadedFile',$tmpFile,$path) and self::canWrite($path) and $storage=self::getStorage($path)){ $run=true; $exists=self::file_exists($path); @@ -403,7 +403,7 @@ class OC_Filesystem{ if($run){ OC_Hook::emit( 'OC_Filesystem', 'write', array( 'path' => $path, 'run' => &$run)); } - error_log('upload2'); + if(defined("DEBUG") && DEBUG) {error_log('upload2');} if($run){ $result=$storage->fromUploadedFile($tmpFile,self::getInternalPath($path)); if(!$exists){ diff --git a/lib/installer.php b/lib/installer.php index 83c575032ec..9416a42c972 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'])){ - error_log("No source specified when installing app"); + if(defined("DEBUG") && DEBUG) {error_log("No source specified when installing app");} 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'])){ - error_log("No href specified when installing app from http"); + if(defined("DEBUG") && DEBUG) {error_log("No href specified when installing app from http");} return false; } copy($data['href'],$path); }else{ if(!isset($data['path'])){ - error_log("No path specified when installing app from local file"); + if(defined("DEBUG") && DEBUG) {error_log("No path specified when installing app from local file");} return false; } $path=$data['path']; @@ -85,7 +85,7 @@ class OC_Installer{ $zip->extractTo($extractDir); $zip->close(); } else { - error_log("Failed to open archive when installing app"); + if(defined("DEBUG") && DEBUG) {error_log("Failed to open archive when installing app");} 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')){ - error_log("App does not provide an info.xml file"); + if(defined("DEBUG") && DEBUG) {error_log("App does not provide an info.xml file");} 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'] )){ - error_log("App already installed"); + if(defined("DEBUG") && DEBUG) {error_log("App already installed");} 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)){ - error_log("App's directory already exists"); + if(defined("DEBUG") && DEBUG) {error_log("App's directory already exists");} 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)){ - error_log('Can\'t create app folder ('.$basedir.')'); + if(defined("DEBUG") && DEBUG) {error_log('Can\'t create app folder ('.$basedir.')');} OC_Helper::rmdirr($extractDir); if($data['source']=='http'){ unlink($path); diff --git a/lib/preferences.php b/lib/preferences.php index 5af007f0223..b4bd6777f9e 100644 --- a/lib/preferences.php +++ b/lib/preferences.php @@ -140,7 +140,7 @@ 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(); - error_log(print_r($values,true)); + if(defined("DEBUG") && DEBUG) {error_log(print_r($values,true));} $exists=(count($values)>0); if( !$exists ){