]> source.dussan.org Git - nextcloud-server.git/commitdiff
only call error_log() if DEBUG is true
authorFlorian Pritz <bluewind@xinu.at>
Thu, 22 Sep 2011 17:24:32 +0000 (19:24 +0200)
committerFlorian Pritz <bluewind@xinu.at>
Sat, 24 Sep 2011 16:41:47 +0000 (18:41 +0200)
Signed-off-by: Florian Pritz <bluewind@xinu.at>
19 files changed:
3rdparty/XML/RPC.php
apps/files_publiclink/lib_public.php
apps/media/ajax/autoupdate.php
apps/media/lib_ampache.php
apps/media/lib_media.php
apps/media/lib_scanner.php
apps/media/server/xml.server.php
apps/unhosted/lib_unhosted.php
apps/user_openid/appinfo/app.php
apps/user_openid/phpmyid.php
apps/user_openid/user.php
config/config.sample.php
files/ajax/newfolder.php
index.php
lib/db.php
lib/filestorage/local.php
lib/filesystem.php
lib/installer.php
lib/preferences.php

index 2cdb44f4aea2da2a05bb21a005f61c24276c4bdc..096b22a0ab5f6146808ab09715c6f7afe500a40a 100644 (file)
@@ -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);
index ece0a540d398403db612d6571827f4a4337dd5d0..f895615380dec3ffa4c304ec3ca8e4dda4f84d1d 100644 (file)
@@ -14,7 +14,7 @@ class OC_PublicLink{
                        if( PEAR::isError($result)) {
                                $entry = 'DB Error: "'.$result->getMessage().'"<br />';
                                $entry .= 'Offending command was: '.$result->getDebugInfo().'<br />';
-                               error_log( $entry );
+                               if(defined("DEBUG") && DEBUG) {error_log( $entry );}
                                die( $entry );
                        }
                        $this->token=$token;
index ded1fd02bc39a7abd1d6c3b8c1720ef13cd0ef8d..ac3d0650b4bc73d47209c0d26c987dcb70214214 100644 (file)
@@ -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);
 
index dc88e35a6972ee48e3b08ab1507e4d417ae48408..87291958af3b1c431c97d93a4e8c38ca14de7f6b 100644 (file)
@@ -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('<root>');
                foreach($artists as $artist){
                        self::printArtist($artist);
index 3086f84a93a6794b8f46524c6622d14b25927fc8..1d8321a774cf5de7ac1f4939b31b960c57843d9e 100644 (file)
@@ -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();
index c774c3c9fdb69ff45d1205266d0cec0904424b68..9bf9397b19a37bc290529f44a1d9bc99b3e7c150 100644 (file)
@@ -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]);
index e61fadf234c816db6d003ee9755a4f24fd661b5a..387c3480047557f8bca02024d1ea845b3dded5d6 100644 (file)
@@ -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);
index 59dc380c45c3997eee55cb6f0b04ea77232cdbee..484f469f0ed388b7c8c8eb95c9d42c24885fdadf 100644 (file)
@@ -7,7 +7,7 @@ class OC_UnhostedWeb {
                if( PEAR::isError($result)) {
                        $entry = 'DB Error: "'.$result->getMessage().'"<br />';
                        $entry .= 'Offending command was: '.$result->getDebugInfo().'<br />';
-                       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().'"<br />';
                        $entry .= 'Offending command was: '.$result->getDebugInfo().'<br />';
-                       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().'"<br />';
                        $entry .= 'Offending command was: '.$result->getDebugInfo().'<br />';
-                       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().'"<br />';
                        $entry .= 'Offending command was: '.$result->getDebugInfo().'<br />';
-                       error_log( $entry );
+                       if(defined("DEBUG") && DEBUG) {error_log( $entry );}
                        die( $entry );
                }
        }
index 578f8f4dadeb9db82c9d50f2e25dcf3bf2d479b5..546f9f4565aa57ebb03e81e596e9d3ad57029029 100644 (file)
@@ -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;
 }
 
index 24fab44ca7aa0281d33834bb804c33e9fa7c53ec..09538b61ab16a3ffed0f97be75cd19d5cdf08286 100644 (file)
@@ -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 ) {
 </body>
 </html>
 ';
-       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))
index 60e12ed88e06847f39733655121627025f12420b..d90e0b71900b813deb3ec3c3a10d2ddb4050a784 100644 (file)
@@ -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;
index 5575340bc1be27455f72fcfdbcc8836dbd6bbc37..a40ce073bf67516d9c60dd122aee8cdb4f7e2d4b 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+define("DEBUG", true);
+
 $CONFIG = array(
 "installed" => false,
 "dbtype" => "sqlite",
index 610418583bd680bfb334047ef59f506fb4f4a7dd..8eb05280e73f435f7cbc37b4251c274a227f6b51 100644 (file)
@@ -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();
index 23bc4fb7764c3434d7e9e48cb70c3a2e22be5ab7..26e90ddfa5c9a39b1f69891aeba3493e1e300e49 100644 (file)
--- 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);
index 0b7065eec8b95e98c7387f196a7727045fa20309..ede8ba897e9ee321d88b859b634ab5fe160f9817 100644 (file)
@@ -92,8 +92,8 @@ class OC_DB {
                        if( PEAR::isError( self::$DBConnection )){
                                echo( '<b>can not connect to database, using '.$CONFIG_DBTYPE.'. ('.self::$DBConnection->getUserInfo().')</center>');
                                $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().'"<br />';
                        $entry .= 'Offending command was: '.$query.'<br />';
-                       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().'"<br />';
                        $entry .= 'Offending command was: '.$query.'<br />';
-                       error_log( $entry );
+                       if(defined("DEBUG") && DEBUG) {error_log( $entry );}
                        die( $entry );
                }
 
index 07759b0e88c9af7353b4e353a3fbf3e1656b50e6..180b056f344edf2fc5c48f2db7f92a38f7a3fb2c 100644 (file)
@@ -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;
index 76032fae204483ac0c7032d0b7cdcd309f22ab1a..f242a1b158e5adfa03416a383307452a0bc5fb50 100644 (file)
@@ -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){
index 83c575032ec9cb4bc6aa58b35984056263090e26..9416a42c972ee8b4a5e2f2b06549527b61ab55bc 100644 (file)
@@ -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);
index 5af007f02238a74466b4ed67403017a0316317af..b4bd6777f9eeeb1ced02624b41214d56f28e7fdd 100644 (file)
@@ -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 ){