From a113ee9e9fd07ab10472746ae8fdfeb61c3d7aeb Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sun, 24 Jun 2012 00:42:16 +0200 Subject: [PATCH 01/48] add x-webkit-speech to searchbox --- core/templates/layout.user.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index d6911fd1e18..7e98fdedc2d 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -47,7 +47,7 @@ ownCloud <?php echo $l->t('Log out');?> From ca5de26bacf6d8a2245a8d916eaa642c3415bd5f Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Sun, 24 Jun 2012 09:41:37 +0200 Subject: [PATCH 02/48] another fix for oc-1044 --- apps/calendar/ajax/event/edit.form.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/calendar/ajax/event/edit.form.php b/apps/calendar/ajax/event/edit.form.php index 26a0cc2a60a..86dff7b75a7 100644 --- a/apps/calendar/ajax/event/edit.form.php +++ b/apps/calendar/ajax/event/edit.form.php @@ -28,7 +28,7 @@ $dtstart = $vevent->DTSTART; $dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent); switch($dtstart->getDateType()) { case Sabre_VObject_Property_DateTime::UTC: - $timeOffset = OC_Calendar_App::$tz*60; + $timeOffset = $_SESSION['timezone']*60; $newDT = $dtstart->getDateTime(); $newDT->add(new DateInterval("PT" . $timeOffset . "M")); $dtstart->setDateTime($newDT); From 0ab6e2ee3d88c9e2e3ada339ccd9b9f921d70598 Mon Sep 17 00:00:00 2001 From: Brice Maron Date: Sun, 24 Jun 2012 08:06:42 +0000 Subject: [PATCH 03/48] Try to fix the remote pbm. fix oc-1090 --- remote.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/remote.php b/remote.php index ef610f36947..976012dea5a 100644 --- a/remote.php +++ b/remote.php @@ -20,16 +20,19 @@ if(is_null($file)){ OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND); exit; } -if(count(explode('/',$file)) == 3) { + +$file = ltrim ($file, '/'); + +if(count(explode('/',$file)) == 2) { $parts=explode('/',$file); - $app=$parts[2]; + $app=$parts[1]; OC_App::loadApp($app); $baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/'; - require_once( OC::$SERVERROOT.$file); + require_once( OC::$SERVERROOT.'/'.$file); } else { - $parts=explode('/', $file, 4); - $app=$parts[2]; + $parts=explode('/', $file, 2); + $app=$parts[0]; OC_App::loadApp($app); $baseuri = OC::$WEBROOT . '/remote.php/'.$service.'/'; - require_once(OC_App::getAppPath($app) .'/'. $parts[3]); + require_once(OC_App::getAppPath($app) .'/'. $parts[1]); } From 9e6d2f2f82322f499722c7db8b8df5d9469ea1e5 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sun, 24 Jun 2012 01:48:37 +0200 Subject: [PATCH 04/48] Improve prev/next selection on delete. --- apps/contacts/js/contacts.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 6f5602c2112..0654976a6dd 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -380,12 +380,12 @@ Contacts={ if(jsondata.status == 'success'){ var newid = '', bookid; var curlistitem = $('#contacts li[data-id="'+jsondata.data.id+'"]'); - var newlistitem = curlistitem.prev(); + var newlistitem = curlistitem.prev('li'); if(newlistitem == undefined) { - newlistitem = curlistitem.next(); + newlistitem = curlistitem.next('li'); } curlistitem.remove(); - if(newlistitem != undefined) { + if(!$(newlistitem).is('li')) { newid = newlistitem.data('id'); bookid = newlistitem.data('id'); } From b182e6c86a8ca0ef4e74f134bbb29e1db1fc5497 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sun, 24 Jun 2012 01:57:08 +0200 Subject: [PATCH 05/48] Trim trailing whitespace from version. --- lib/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/app.php b/lib/app.php index 84d17957def..b337c55ec60 100755 --- a/lib/app.php +++ b/lib/app.php @@ -381,7 +381,7 @@ class OC_App{ $file= self::getAppPath($appid).'/appinfo/version'; $version=@file_get_contents($file); if($version){ - return $version; + return trim($version); }else{ $appData=self::getAppInfo($appid); return $appData['version']; From 5393c0cfedf9ab07276e43e02fbe75e397671df0 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sun, 24 Jun 2012 16:03:10 +0200 Subject: [PATCH 06/48] Click to select which address book to add to. --- apps/contacts/css/contacts.css | 2 +- apps/contacts/js/contacts.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/contacts/css/contacts.css b/apps/contacts/css/contacts.css index 6c65db2b772..fb5bcb2b70c 100644 --- a/apps/contacts/css/contacts.css +++ b/apps/contacts/css/contacts.css @@ -5,7 +5,7 @@ #leftcontent a { padding: 0 0 0 25px; } #rightcontent { top: 3.5em !important; padding-top: 5px; } #leftcontent h3 { cursor: pointer; -moz-transition: background 300ms ease 0s; background: none no-repeat scroll 1em center #eee; border-bottom: 1px solid #ddd; border-top: 1px solid #fff; display: block; max-width: 100%; padding: 0.5em 0.8em; color: #666; text-shadow: 0 1px 0 #f8f8f8; font-size: 1.2em; } -#leftcontent h3:hover { background-color: #DBDBDB; border-bottom: 1px solid #CCCCCC; border-top: 1px solid #D4D4D4; color: #333333; } +#leftcontent h3:hover,#leftcontent h3:active,#leftcontent h3.active { background-color: #DBDBDB; border-bottom: 1px solid #CCCCCC; border-top: 1px solid #D4D4D4; color: #333333; } #contacts { position: fixed; background: #fff; max-width: 100%; width: 20em; left: 12.5em; top: 3.7em; bottom: 3em; overflow: auto; padding: 0; margin: 0; } .contacts a { height: 23px; display: block; left: 12.5em; margin: 0 0 0 0; padding: 0 0 0 25px; } #bottomcontrols { padding: 0; bottom:0px; height:2.8em; width: 20em; margin:0; background:#eee; border-top:1px solid #ccc; position:fixed; -moz-box-shadow: 0 -3px 3px -3px #000; -webkit-box-shadow: 0 -3px 3px -3px #000; box-shadow: 0 -3px 3px -3px #000;} diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 0654976a6dd..0325b2cec2a 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -310,10 +310,11 @@ Contacts={ editNew:function(){ // add a new contact this.id = ''; this.fn = ''; this.fullname = ''; this.givname = ''; this.famname = ''; this.addname = ''; this.honpre = ''; this.honsuf = ''; //Contacts.UI.Card.add(t('contacts', 'Contact')+';'+t('contacts', 'New')+';;;', t('contacts', 'New Contact'), '', true); - Contacts.UI.Card.add(';;;;;', '', '', true); + Contacts.UI.Card.add(';;;;;', '', this.bookid, true); return false; }, add:function(n, fn, aid, isnew){ // add a new contact + aid = aid?aid:$('#contacts h3.active').first().data('id'); var localAddcontact = function(n, fn, aid, isnew) { $.post(OC.filePath('contacts', 'ajax', 'addcontact.php'), { n: n, fn: fn, aid: aid, isnew: isnew }, function(jsondata) { @@ -1605,6 +1606,8 @@ $(document).ready(function(){ }); $(document).on('click', '.addressbook', function(event){ + $('#contacts h3').removeClass('active'); + $(this).addClass('active'); $(this).next().slideToggle(300); return false; }); From 0f9b9fa111208925f2d4518e40476d5f68b6f940 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sun, 24 Jun 2012 16:07:18 +0200 Subject: [PATCH 07/48] Remove unneeded parameter. --- apps/contacts/js/contacts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 0325b2cec2a..39e45224858 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -310,7 +310,7 @@ Contacts={ editNew:function(){ // add a new contact this.id = ''; this.fn = ''; this.fullname = ''; this.givname = ''; this.famname = ''; this.addname = ''; this.honpre = ''; this.honsuf = ''; //Contacts.UI.Card.add(t('contacts', 'Contact')+';'+t('contacts', 'New')+';;;', t('contacts', 'New Contact'), '', true); - Contacts.UI.Card.add(';;;;;', '', this.bookid, true); + Contacts.UI.Card.add(';;;;;', '', '', true); return false; }, add:function(n, fn, aid, isnew){ // add a new contact From c53a8fa541dec244085ce551f2b1dd5b18b6e568 Mon Sep 17 00:00:00 2001 From: Brice Maron Date: Sun, 24 Jun 2012 15:11:58 +0000 Subject: [PATCH 08/48] Correct seq name in media songs fix oc-589 --- apps/media/lib_collection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/media/lib_collection.php b/apps/media/lib_collection.php index a32a50534ed..bf82e65e62b 100644 --- a/apps/media/lib_collection.php +++ b/apps/media/lib_collection.php @@ -277,7 +277,7 @@ class OC_MEDIA_COLLECTION{ $query=self::$queries['addsong']; } $query->execute(array($name,$artist,$album,$path,$uid,$length,$track,$size)); - $songId=OCP\DB::insertid('*PREFIX*media_songs'); + $songId=OCP\DB::insertid('*PREFIX*media_songs_song'); // self::setLastUpdated(); return self::getSongId($name,$artist,$album); } From f56b3df0bcb2c678b944f5086adad6e3e678252a Mon Sep 17 00:00:00 2001 From: Brice Maron Date: Sun, 24 Jun 2012 15:58:51 +0000 Subject: [PATCH 09/48] Resolve scanning issue case comparison of songs --- apps/media/lib_collection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/media/lib_collection.php b/apps/media/lib_collection.php index bf82e65e62b..598c08d32e2 100644 --- a/apps/media/lib_collection.php +++ b/apps/media/lib_collection.php @@ -104,7 +104,7 @@ class OC_MEDIA_COLLECTION{ return self::$albumIdCache[$artistId][$albumId][$name]; }else{ $uid=$_SESSION['user_id']; - $query=OCP\DB::prepare("SELECT song_id FROM *PREFIX*media_songs WHERE song_user=? AND song_name LIKE ? AND song_artist=? AND song_album=?"); + $query=OCP\DB::prepare("SELECT song_id FROM *PREFIX*media_songs WHERE song_user=? AND lower(song_name) LIKE ? AND song_artist=? AND song_album=?"); $songs=$query->execute(array($uid,$name,$artistId,$albumId))->fetchAll(); if(is_array($songs) and isset($songs[0])){ self::$albumIdCache[$artistId][$albumId][$name]=$songs[0]['song_id']; From 61adae1e49b67cfe79d5daf2bc9e649b343090bb Mon Sep 17 00:00:00 2001 From: Brice Maron Date: Sun, 24 Jun 2012 19:41:23 +0000 Subject: [PATCH 10/48] Use intervals for sessions deletion with postgres fix oc-492 --- apps/media/lib_ampache.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/media/lib_ampache.php b/apps/media/lib_ampache.php index f5c91661abe..255e6f468f8 100644 --- a/apps/media/lib_ampache.php +++ b/apps/media/lib_ampache.php @@ -77,7 +77,7 @@ class OC_MEDIA_AMPACHE{ $songs=OC_MEDIA_COLLECTION::getSongCount(); $artists=OC_MEDIA_COLLECTION::getArtistCount(); $albums=OC_MEDIA_COLLECTION::getAlbumCount(); - $query=OCP\DB::prepare("INSERT INTO *PREFIX*media_sessions (`session_id`, `token`, `user_id`, `start`) VALUES (NULL, ?, ?, now());"); + $query=OCP\DB::prepare("INSERT INTO *PREFIX*media_sessions (`token`, `user_id`, `start`) VALUES (?, ?, now());"); $query->execute(array($token,$user)); $expire=date('c',time()+600); echo(''); @@ -136,8 +136,14 @@ class OC_MEDIA_AMPACHE{ return false; } } + $CONFIG_DBTYPE = OCP\Config::getSystemValue( "dbtype", "sqlite" ); + if($CONFIG_DBTYPE == 'psql'){ + $interval = ' \'600s\'::interval '; + }else { + $interval = '600'; + } //remove old sessions - $query=OCP\DB::prepare("DELETE from *PREFIX*media_sessions WHERE start<(NOW()-600)"); + $query=OCP\DB::prepare("DELETE from *PREFIX*media_sessions WHERE start<(NOW() - ".$interval.")"); $query->execute(); $query=OCP\DB::prepare("SELECT user_id from *PREFIX*media_sessions WHERE token=?"); From 2a6a155e23626fbbc4b04917b52e2f918e10effc Mon Sep 17 00:00:00 2001 From: Brice Maron Date: Fri, 22 Jun 2012 10:46:49 +0200 Subject: [PATCH 11/48] Correct File cache error with postgresql --- lib/filecache.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/filecache.php b/lib/filecache.php index e3bcc7d0000..13d7b34c9d7 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -110,6 +110,9 @@ class OC_FileCache{ $queryParts=array(); foreach(array('size','mtime','ctime','mimetype','encrypted','versioned','writable') as $attribute){ if(isset($data[$attribute])){ + //Convert to int it args are false + if($data[$attribute] === false) $arguments[] = 0; + else $arguments[] = $data[$attribute]; $arguments[]=$data[$attribute]; $queryParts[]=$attribute.'=?'; } From df1eca4fa2876da3507b51a5a47683284e887c7a Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sun, 24 Jun 2012 22:15:36 +0200 Subject: [PATCH 12/48] Also load categories from VJOURNAL. --- apps/calendar/lib/app.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php index 8e13b13b8a3..344c89f36b0 100644 --- a/apps/calendar/lib/app.php +++ b/apps/calendar/lib/app.php @@ -194,6 +194,9 @@ class OC_Calendar_App{ } else if (isset($calendar->VTODO)) { $object = $calendar->VTODO; + } else + if (isset($calendar->VJOURNAL)) { + $object = $calendar->VJOURNAL; } if ($object) { self::getVCategories()->loadFromVObject($object, true); From f10c51193b0b661a187490f584cc41fbc7a67f01 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sun, 24 Jun 2012 22:21:21 +0200 Subject: [PATCH 13/48] Fixed function name. --- apps/contacts/thumbnail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/contacts/thumbnail.php b/apps/contacts/thumbnail.php index 8378507163e..a69e9c74f72 100644 --- a/apps/contacts/thumbnail.php +++ b/apps/contacts/thumbnail.php @@ -23,7 +23,7 @@ OCP\JSON::checkLoggedIn(); //OCP\User::checkLoggedIn(); OCP\App::checkAppEnabled('contacts'); -session_close_write(); +session_write_close(); function getStandardImage(){ //OCP\Response::setExpiresHeader('P10D'); From 3afbc3d2dc3c36145411926f1b59de0401fe6876 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sun, 24 Jun 2012 22:22:58 +0200 Subject: [PATCH 14/48] Add some DRYness to logging. --- apps/contacts/ajax/addproperty.php | 6 +--- apps/contacts/ajax/categories/delete.php | 13 +------- apps/contacts/ajax/categories/rescan.php | 13 +------- apps/contacts/ajax/contactdetails.php | 6 +--- apps/contacts/ajax/createaddressbook.php | 13 +++----- apps/contacts/ajax/currentphoto.php | 6 +--- apps/contacts/ajax/deletecard.php | 19 +++++------ apps/contacts/ajax/deleteproperty.php | 7 ++--- apps/contacts/ajax/editname.php | 6 +--- apps/contacts/ajax/loadphoto.php | 6 +--- apps/contacts/ajax/loghandler.php | 40 ++++++++++++++++++++++++ apps/contacts/ajax/oc_photo.php | 6 +--- apps/contacts/ajax/savecrop.php | 6 +--- apps/contacts/ajax/saveproperty.php | 12 +------ apps/contacts/ajax/updateaddressbook.php | 13 +++----- apps/contacts/ajax/uploadimport.php | 6 +--- apps/contacts/ajax/uploadphoto.php | 9 +----- 17 files changed, 70 insertions(+), 117 deletions(-) create mode 100644 apps/contacts/ajax/loghandler.php diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php index f888b94e386..1b6db0c8f81 100644 --- a/apps/contacts/ajax/addproperty.php +++ b/apps/contacts/ajax/addproperty.php @@ -25,11 +25,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::callCheck(); -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/addproperty.php: '.$msg, OCP\Util::DEBUG); - exit(); -} +require_once('loghandler.php'); $id = isset($_POST['id'])?$_POST['id']:null; $name = isset($_POST['name'])?$_POST['name']:null; diff --git a/apps/contacts/ajax/categories/delete.php b/apps/contacts/ajax/categories/delete.php index bee2dbe3f6b..76c23d6487d 100644 --- a/apps/contacts/ajax/categories/delete.php +++ b/apps/contacts/ajax/categories/delete.php @@ -10,18 +10,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -foreach ($_POST as $key=>$element) { - debug('_POST: '.$key.'=>'.print_r($element, true)); -} - -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/categories/delete.php: '.$msg, OCP\Util::DEBUG); - exit(); -} -function debug($msg) { - OCP\Util::writeLog('contacts','ajax/categories/delete.php: '.$msg, OCP\Util::DEBUG); -} +require_once('../loghandler.php'); $categories = isset($_POST['categories'])?$_POST['categories']:null; diff --git a/apps/contacts/ajax/categories/rescan.php b/apps/contacts/ajax/categories/rescan.php index 84a67dec0b1..48ec165381f 100644 --- a/apps/contacts/ajax/categories/rescan.php +++ b/apps/contacts/ajax/categories/rescan.php @@ -10,18 +10,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -foreach ($_POST as $key=>$element) { - debug('_POST: '.$key.'=>'.print_r($element, true)); -} - -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/categories/rescan.php: '.$msg, OCP\Util::DEBUG); - exit(); -} -function debug($msg) { - OCP\Util::writeLog('contacts','ajax/categories/rescan.php: '.$msg, OCP\Util::DEBUG); -} +require_once('../loghandler.php'); $addressbooks = OC_Contacts_Addressbook::all(OCP\USER::getUser()); if(count($addressbooks) == 0) { diff --git a/apps/contacts/ajax/contactdetails.php b/apps/contacts/ajax/contactdetails.php index a6ca10f9c94..b697b1a8e5b 100644 --- a/apps/contacts/ajax/contactdetails.php +++ b/apps/contacts/ajax/contactdetails.php @@ -20,11 +20,7 @@ * */ -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/contactdetails.php: '.$msg, OCP\Util::DEBUG); - exit(); -} +require_once('loghandler.php'); // Check if we are a user OCP\JSON::checkLoggedIn(); diff --git a/apps/contacts/ajax/createaddressbook.php b/apps/contacts/ajax/createaddressbook.php index 616766bb1a0..2ec5f542bb3 100644 --- a/apps/contacts/ajax/createaddressbook.php +++ b/apps/contacts/ajax/createaddressbook.php @@ -12,25 +12,20 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::callCheck(); +require_once('loghandler.php'); $userid = OCP\USER::getUser(); $name = trim(strip_tags($_POST['name'])); if(!$name) { - OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot add addressbook with an empty name.')))); - OCP\Util::writeLog('contacts','ajax/createaddressbook.php: Cannot add addressbook with an empty name: '.strip_tags($_POST['name']), OCP\Util::ERROR); - exit(); + bailOut('Cannot add addressbook with an empty name.'); } $bookid = OC_Contacts_Addressbook::add($userid, $name, null); if(!$bookid) { - OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error adding addressbook.')))); - OCP\Util::writeLog('contacts','ajax/createaddressbook.php: Error adding addressbook: '.$_POST['name'], OCP\Util::ERROR); - exit(); + bailOut('Error adding addressbook: '.$name); } if(!OC_Contacts_Addressbook::setActive($bookid, 1)) { - OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error activating addressbook.')))); - OCP\Util::writeLog('contacts','ajax/createaddressbook.php: Error activating addressbook: '.$bookid, OCP\Util::ERROR); - //exit(); + bailOut('Error activating addressbook.'); } $addressbook = OC_Contacts_App::getAddressbook($bookid); $tmpl = new OCP\Template('contacts', 'part.chooseaddressbook.rowfields'); diff --git a/apps/contacts/ajax/currentphoto.php b/apps/contacts/ajax/currentphoto.php index 5f90128f321..b10e752c453 100644 --- a/apps/contacts/ajax/currentphoto.php +++ b/apps/contacts/ajax/currentphoto.php @@ -24,11 +24,7 @@ OCP\JSON::setContentTypeHeader('text/plain'); OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/currentphoto.php: '.$msg, OCP\Util::ERROR); - exit(); -} +require_once('loghandler.php'); if (!isset($_GET['id'])) { bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.')); diff --git a/apps/contacts/ajax/deletecard.php b/apps/contacts/ajax/deletecard.php index 2a6bd277d19..1161c18abda 100644 --- a/apps/contacts/ajax/deletecard.php +++ b/apps/contacts/ajax/deletecard.php @@ -19,26 +19,21 @@ * License along with this library. If not, see . * */ -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/saveproperty.php: '.$msg, OCP\Util::DEBUG); - exit(); -} - // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::callCheck(); +require_once('loghandler.php'); // foreach($_SERVER as $key=>$value) { // OCP\Util::writeLog('contacts','ajax/saveproperty.php: _SERVER: '.$key.'=>'.$value, OCP\Util::DEBUG); // } -foreach($_POST as $key=>$value) { - OCP\Util::writeLog('contacts','ajax/saveproperty.php: _POST: '.$key.'=>'.print_r($value, true), OCP\Util::DEBUG); -} -foreach($_GET as $key=>$value) { - OCP\Util::writeLog('contacts','ajax/saveproperty.php: _GET: '.$key.'=>'.print_r($value, true), OCP\Util::DEBUG); -} +// foreach($_POST as $key=>$value) { +// debug($key.'=>'.print_r($value, true)); +// } +// foreach($_GET as $key=>$value) { +// debug($key.'=>'.print_r($value, true)); +// } $id = isset($_POST['id'])?$_POST['id']:null; if(!$id) { diff --git a/apps/contacts/ajax/deleteproperty.php b/apps/contacts/ajax/deleteproperty.php index 55f7e323083..90e5e64903e 100644 --- a/apps/contacts/ajax/deleteproperty.php +++ b/apps/contacts/ajax/deleteproperty.php @@ -24,6 +24,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::callCheck(); +require_once('loghandler.php'); $id = $_POST['id']; $checksum = $_POST['checksum']; @@ -31,16 +32,14 @@ $checksum = $_POST['checksum']; $vcard = OC_Contacts_App::getContactVCard( $id ); $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum); if(is_null($line)){ - OCP\JSON::error(array('data' => array( 'message' => OC_Contacts_App::$l10n->t('Information about vCard is incorrect. Please reload the page.')))); + bailOut(OC_Contacts_App::$l10n->t('Information about vCard is incorrect. Please reload the page.')); exit(); } unset($vcard->children[$line]); if(!OC_Contacts_VCard::edit($id,$vcard)) { - OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error deleting contact property.')))); - OCP\Util::writeLog('contacts','ajax/deleteproperty.php: Error deleting contact property', OCP\Util::ERROR); - exit(); + bailOut(OC_Contacts_App::$l10n->t('Error deleting contact property.')); } OCP\JSON::success(array('data' => array( 'id' => $id ))); diff --git a/apps/contacts/ajax/editname.php b/apps/contacts/ajax/editname.php index 62cae894b6f..868ca222e0a 100644 --- a/apps/contacts/ajax/editname.php +++ b/apps/contacts/ajax/editname.php @@ -9,11 +9,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/editname.php: '.$msg, OCP\Util::DEBUG); - exit(); -} +require_once('loghandler.php'); $tmpl = new OCP\Template("contacts", "part.edit_name_dialog"); diff --git a/apps/contacts/ajax/loadphoto.php b/apps/contacts/ajax/loadphoto.php index eac7ca7d02f..61b5356edce 100644 --- a/apps/contacts/ajax/loadphoto.php +++ b/apps/contacts/ajax/loadphoto.php @@ -24,11 +24,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/loadphoto.php: '.$msg, OCP\Util::DEBUG); - exit(); -} +require_once('loghandler.php'); $id = isset($_GET['id']) ? $_GET['id'] : ''; $refresh = isset($_GET['refresh']) ? true : false; diff --git a/apps/contacts/ajax/loghandler.php b/apps/contacts/ajax/loghandler.php new file mode 100644 index 00000000000..831b2e50c1e --- /dev/null +++ b/apps/contacts/ajax/loghandler.php @@ -0,0 +1,40 @@ + + * + * 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 . + * + */ + +function bailOut($msg, $tracelevel=1, $debuglevel=OCP\Util::ERROR) { + OCP\JSON::error(array('data' => array('message' => $msg))); + debug($msg, $tracelevel, $debuglevel); + exit(); +} + +function debug($msg, $tracelevel=0, $debuglevel=OCP\Util::DEBUG) { + if(PHP_VERSION >= "5.4") { + $call = debug_backtrace(false, $tracelevel+1); + } else { + $call = debug_backtrace(false); + } + error_log('trace: '.print_r($call, true)); + $call = $call[$tracelevel]; + if($debuglevel !== false) { + OCP\Util::writeLog('contacts', $call['file'].'. Line: '.$call['line'].': '.$msg, $debuglevel); + } +} diff --git a/apps/contacts/ajax/oc_photo.php b/apps/contacts/ajax/oc_photo.php index ea25ebf1763..5c50ba92dbe 100644 --- a/apps/contacts/ajax/oc_photo.php +++ b/apps/contacts/ajax/oc_photo.php @@ -22,11 +22,7 @@ // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/oc_photo.php: '.$msg, OCP\Util::ERROR); - exit(); -} +require_once('loghandler.php'); if(!isset($_GET['id'])) { bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.')); diff --git a/apps/contacts/ajax/savecrop.php b/apps/contacts/ajax/savecrop.php index 6faf6a173d5..adce6be3b39 100644 --- a/apps/contacts/ajax/savecrop.php +++ b/apps/contacts/ajax/savecrop.php @@ -27,11 +27,7 @@ OCP\JSON::callCheck(); // Firefox and Konqueror tries to download application/json for me. --Arthur OCP\JSON::setContentTypeHeader('text/plain'); -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/savecrop.php: '.$msg, OCP\Util::DEBUG); - exit(); -} +require_once('loghandler.php'); $image = null; diff --git a/apps/contacts/ajax/saveproperty.php b/apps/contacts/ajax/saveproperty.php index 6ee9ec90b56..34fc3cc5351 100644 --- a/apps/contacts/ajax/saveproperty.php +++ b/apps/contacts/ajax/saveproperty.php @@ -19,21 +19,11 @@ * License along with this library. If not, see . * */ - -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/saveproperty.php: '.$msg, OCP\Util::DEBUG); - exit(); -} -function debug($msg) { - OCP\Util::writeLog('contacts','ajax/saveproperty.php: '.$msg, OCP\Util::DEBUG); -} - +require_once('loghandler.php'); // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::callCheck(); - $id = isset($_POST['id'])?$_POST['id']:null; $name = isset($_POST['name'])?$_POST['name']:null; $value = isset($_POST['value'])?$_POST['value']:null; diff --git a/apps/contacts/ajax/updateaddressbook.php b/apps/contacts/ajax/updateaddressbook.php index 19b5b3bddce..d3a772c727f 100644 --- a/apps/contacts/ajax/updateaddressbook.php +++ b/apps/contacts/ajax/updateaddressbook.php @@ -11,27 +11,22 @@ // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); +require_once('loghandler.php'); $bookid = $_POST['id']; OC_Contacts_App::getAddressbook($bookid); // is owner access check $name = trim(strip_tags($_POST['name'])); if(!$name) { - OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Cannot update addressbook with an empty name.')))); - OCP\Util::writeLog('contacts','ajax/updateaddressbook.php: Cannot update addressbook with an empty name: '.strip_tags($_POST['name']), OCP\Util::ERROR); - exit(); + bailOut(OC_Contacts_App::$l10n->t('Cannot update addressbook with an empty name.')); } if(!OC_Contacts_Addressbook::edit($bookid, $name, null)) { - OCP\JSON::error(array('data' => array('message' => $l->t('Error updating addressbook.')))); - OCP\Util::writeLog('contacts','ajax/updateaddressbook.php: Error adding addressbook: ', OCP\Util::ERROR); - //exit(); + bailOut(OC_Contacts_App::$l10n->t('Error updating addressbook.')); } if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) { - OCP\JSON::error(array('data' => array('message' => $l->t('Error (de)activating addressbook.')))); - OCP\Util::writeLog('contacts','ajax/updateaddressbook.php: Error (de)activating addressbook: '.$bookid, OCP\Util::ERROR); - //exit(); + bailOut(OC_Contacts_App::$l10n->t('Error (de)activating addressbook.')); } $addressbook = OC_Contacts_App::getAddressbook($bookid); diff --git a/apps/contacts/ajax/uploadimport.php b/apps/contacts/ajax/uploadimport.php index 463ca161e56..c1e9c8b1ad1 100644 --- a/apps/contacts/ajax/uploadimport.php +++ b/apps/contacts/ajax/uploadimport.php @@ -23,11 +23,7 @@ // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/uploadimport.php: '.$msg, OCP\Util::ERROR); - exit(); -} +require_once('loghandler.php'); $view = OCP\Files::getStorage('contacts'); $tmpfile = md5(rand()); diff --git a/apps/contacts/ajax/uploadphoto.php b/apps/contacts/ajax/uploadphoto.php index 889de6a1f8b..8545ca84eee 100644 --- a/apps/contacts/ajax/uploadphoto.php +++ b/apps/contacts/ajax/uploadphoto.php @@ -27,14 +27,7 @@ OCP\JSON::callCheck(); // Firefox and Konqueror tries to download application/json for me. --Arthur OCP\JSON::setContentTypeHeader('text/plain'); -function bailOut($msg) { - OCP\JSON::error(array('data' => array('message' => $msg))); - OCP\Util::writeLog('contacts','ajax/uploadphoto.php: '.$msg, OCP\Util::DEBUG); - exit(); -} -function debug($msg) { - OCP\Util::writeLog('contacts','ajax/uploadphoto.php: '.$msg, OCP\Util::DEBUG); -} +require_once('loghandler.php'); // If it is a Drag'n'Drop transfer it's handled here. $fn = (isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : false); From e845e567496c38aa56cda9f217f52aedf8b05f57 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sun, 24 Jun 2012 22:24:54 +0200 Subject: [PATCH 15/48] Remove excessive debugging. --- apps/contacts/ajax/contacts.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/apps/contacts/ajax/contacts.php b/apps/contacts/ajax/contacts.php index 16730ec9474..2ce6de1696b 100644 --- a/apps/contacts/ajax/contacts.php +++ b/apps/contacts/ajax/contacts.php @@ -18,7 +18,6 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); $active_addressbooks = OC_Contacts_Addressbook::active(OCP\USER::getUser()); -error_log('active_addressbooks: '.print_r($active_addressbooks, true)); $contacts_addressbook = array(); $ids = array(); @@ -29,9 +28,7 @@ foreach($active_addressbooks as $addressbook) { $contacts_addressbook[$addressbook['id']]['displayname'] = $addressbook['displayname']; } } -error_log('ids: '.print_r($ids, true)); $contacts_alphabet = OC_Contacts_VCard::all($ids); -error_log('contacts_alphabet: '.print_r($contacts_alphabet, true)); // Our new array for the contacts sorted by addressbook foreach($contacts_alphabet as $contact) { From 564cd825997461218c4efbd5d4c3877e1f815353 Mon Sep 17 00:00:00 2001 From: Brice Maron Date: Sun, 24 Jun 2012 20:49:48 +0000 Subject: [PATCH 16/48] Fix the fix about filecache and postgres --- lib/filecache.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/filecache.php b/lib/filecache.php index 13d7b34c9d7..d956f34dc48 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -111,9 +111,8 @@ class OC_FileCache{ foreach(array('size','mtime','ctime','mimetype','encrypted','versioned','writable') as $attribute){ if(isset($data[$attribute])){ //Convert to int it args are false - if($data[$attribute] === false) $arguments[] = 0; + if($data[$attribute] === false) $arguments[] = 0; else $arguments[] = $data[$attribute]; - $arguments[]=$data[$attribute]; $queryParts[]=$attribute.'=?'; } } From 0fb9d0bf29a18c6fd463a4a62fcada2f473685d2 Mon Sep 17 00:00:00 2001 From: Brice Maron Date: Sun, 24 Jun 2012 21:24:43 +0000 Subject: [PATCH 17/48] Correct bookmark app : add through interface and remove missing css --- apps/bookmarks/ajax/addBookmark.php | 2 +- apps/bookmarks/templates/addBm.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/bookmarks/ajax/addBookmark.php b/apps/bookmarks/ajax/addBookmark.php index d66aab58960..6b5a0f71d4e 100644 --- a/apps/bookmarks/ajax/addBookmark.php +++ b/apps/bookmarks/ajax/addBookmark.php @@ -31,5 +31,5 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('bookmarks'); require_once(OC_App::getAppPath('bookmarks').'/bookmarksHelper.php'); -$id = addBookmark($_GET['url'], $_GET['title'], $_GET['tags']); +$id = addBookmark($_POST['url'], $_POST['title'], $_POST['tags']); OCP\JSON::success(array('data' => $id)); \ No newline at end of file diff --git a/apps/bookmarks/templates/addBm.php b/apps/bookmarks/templates/addBm.php index dbe673f53a8..534bafe5885 100644 --- a/apps/bookmarks/templates/addBm.php +++ b/apps/bookmarks/templates/addBm.php @@ -3,7 +3,6 @@ Read later - ownCloud -

Saved!

From 51d33768b84fe8467258bfe67a1f9cd7e0f0913a Mon Sep 17 00:00:00 2001 From: Brice Maron Date: Sun, 24 Jun 2012 21:30:14 +0000 Subject: [PATCH 18/48] Prevent errors and mini enhancement of saved window in bookmarks --- apps/bookmarks/bookmarksHelper.php | 3 ++- apps/bookmarks/templates/addBm.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/bookmarks/bookmarksHelper.php b/apps/bookmarks/bookmarksHelper.php index 01b551111e0..92baac2f511 100644 --- a/apps/bookmarks/bookmarksHelper.php +++ b/apps/bookmarks/bookmarksHelper.php @@ -90,7 +90,8 @@ function addBookmark($url, $title, $tags='') { if(empty($title)) { $metadata = getURLMetadata($url); - $title = $metadata['title']; + if(isset($metadata['title'])) // Check for problems fetching the title + $title = $metadata['title']; } if(empty($title)) { diff --git a/apps/bookmarks/templates/addBm.php b/apps/bookmarks/templates/addBm.php index 534bafe5885..357e0a18f25 100644 --- a/apps/bookmarks/templates/addBm.php +++ b/apps/bookmarks/templates/addBm.php @@ -6,5 +6,6 @@

Saved!

+ Close the window \ No newline at end of file From 052bd8efbb39096867fdb2c0922b77f468a45ef9 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Mon, 25 Jun 2012 03:41:28 +0200 Subject: [PATCH 19/48] Drag'n'Drop contacts between addressbook. Still needs some css magic. --- apps/contacts/ajax/movetoaddressbook.php | 41 ++++++++++++++++++++++++ apps/contacts/js/contacts.js | 36 +++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 apps/contacts/ajax/movetoaddressbook.php diff --git a/apps/contacts/ajax/movetoaddressbook.php b/apps/contacts/ajax/movetoaddressbook.php new file mode 100644 index 00000000000..a3336c3cb6c --- /dev/null +++ b/apps/contacts/ajax/movetoaddressbook.php @@ -0,0 +1,41 @@ + +* Copyright (c) 2012 Thomas Tanghus +* This file is licensed under the Affero General Public License version 3 or +* later. +* See the COPYING-README file. +*/ + +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('contacts'); +OCP\JSON::callCheck(); + +$ids = $_POST['ids']; +$aid = intval($_POST['aid']); +OC_Contacts_App::getAddressbook($aid); + +if(!is_array($ids)) { + $ids = array($ids,); +} +$goodids = array(); +foreach ($ids as $id){ + try { + $card = OC_Contacts_App::getContactObject( intval($id) ); + if($card) { + $goodids[] = $id; + } + } catch (Exception $e) { + OCP\Util::writeLog('contacts', 'Error moving contact "'.$id.'" to addressbook "'.$aid.'"'.$e->getMessage(), OCP\Util::ERROR); + } +} +try { + OC_Contacts_VCard::moveToAddressBook($aid, $ids); +} catch (Exception $e) { + $msg = $e->getMessage(); + OCP\Util::writeLog('contacts', 'Error moving contacts "'.implode(',', $ids).'" to addressbook "'.$aid.'"'.$msg, OCP\Util::ERROR); + OC_JSON::error(array('data' => array('message' => $msg,))); +} + +OC_JSON::success(array('data' => array('ids' => $goodids,))); \ No newline at end of file diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 39e45224858..d5f09fbc722 100644 --- a/apps/contacts/js/contacts.js +++ b/apps/contacts/js/contacts.js @@ -1505,6 +1505,36 @@ Contacts={ } }, Contacts:{ + drop:function(event, ui) { + var dragitem = ui.draggable, droptarget = $(this); + //console.log('Drop ' + dragitem.data('id') +' on: ' + droptarget.data('id')); + if(dragitem.data('bookid') == droptarget.data('id')) { + return false; + } + var droplist = (droptarget.is('ul'))?droptarget:droptarget.next(); + $.post(OC.filePath('contacts', 'ajax', 'movetoaddressbook.php'), { ids: dragitem.data('id'), aid: $(this).data('id') }, + function(jsondata){ + if(jsondata.status == 'success'){ + // Do some inserting/removing/sorting magic + var name = $(dragitem).find('a').html(); + var added = false; + $(droplist).children().each(function(){ + if ($(this).text().toLowerCase() > name.toLowerCase()) { + $(this).before(dragitem.detach()); //.fadeIn('slow'); + added = true; + return false; + } + }); + if(!added) { + $(droplist).append(dragitem.detach()); + } + dragitem.data('bookid', droptarget.data('id')); + Contacts.UI.Contacts.scrollTo(dragitem.data('id')); + } else { + OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error')); + } + }); + }, // Reload the contacts list. update:function(id){ $.getJSON(OC.filePath('contacts', 'ajax', 'contacts.php'),{},function(jsondata){ @@ -1522,6 +1552,12 @@ Contacts={ setTimeout(Contacts.UI.Contacts.lazyupdate, 500);*/ }); Contacts.UI.Card.update(id); + $('#contacts h3,#contacts ul').droppable({ drop: Contacts.UI.Contacts.drop}); + $('#contacts li').draggable({ + axis: 'y', containment: '#contacts', + scroll: true, scrollSensitivity: 100, + opacity: 0.7, helper: 'clone' + }); } else{ OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error')); From c3130919c2fa67caa5d7d52124b20388633c5cfa Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Mon, 25 Jun 2012 05:02:01 +0200 Subject: [PATCH 20/48] Allow direct link to app. --- settings/apps.php | 2 ++ settings/js/apps.js | 9 +++++++++ settings/templates/apps.php | 4 +++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/settings/apps.php b/settings/apps.php index f85b28158f5..f4ae8b8d977 100644 --- a/settings/apps.php +++ b/settings/apps.php @@ -93,6 +93,8 @@ usort($apps, 'app_sort'); $tmpl = new OC_Template( "settings", "apps", "user" ); $tmpl->assign('apps',$apps, false); +$appid = (isset($_GET['appid'])?strip_tags($_GET['appid']):''); +$tmpl->assign('appid',$appid); $tmpl->printPage(); diff --git a/settings/js/apps.js b/settings/js/apps.js index 224076aba43..cfef894c6fb 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -73,4 +73,13 @@ $(document).ready(function(){ } } }); + + if(appid) { + var item = $('#leftcontent li[data-id="'+appid+'"]'); + if(item) { + item.trigger('click'); + item.addClass('active'); + $('#leftcontent').animate({scrollTop: $(item).offset().top-70}, 'slow','swing'); + } + } }); diff --git a/settings/templates/apps.php b/settings/templates/apps.php index c620f796e06..b9beedca151 100644 --- a/settings/templates/apps.php +++ b/settings/templates/apps.php @@ -3,7 +3,9 @@ * This file is licensed under the Affero General Public License version 3 or later. * See the COPYING-README file. */?> - + From 5ac4830e757eb07ff2ca993954f2c31bbe80185f Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Mon, 25 Jun 2012 05:03:30 +0200 Subject: [PATCH 21/48] XSS fix. --- settings/templates/apps.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings/templates/apps.php b/settings/templates/apps.php index b9beedca151..6edaf6c5848 100644 --- a/settings/templates/apps.php +++ b/settings/templates/apps.php @@ -12,7 +12,7 @@
  • data-id=""> - + From 9ee528bc74a924def23168cd2ef8ccbdcbc649c8 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Mon, 25 Jun 2012 10:15:20 +0200 Subject: [PATCH 22/48] Only delete existing thumbnails (bug #1100) --- apps/gallery/lib/managers.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/gallery/lib/managers.php b/apps/gallery/lib/managers.php index d4d978dbdd0..fcce3f40e23 100644 --- a/apps/gallery/lib/managers.php +++ b/apps/gallery/lib/managers.php @@ -86,7 +86,10 @@ class ThumbnailsManager { } public function delete($path) { - unlink(\OCP\Config::getSystemValue('datadirectory').'/'.\OC_User::getUser()."/gallery".$path); + $thumbnail = \OCP\Config::getSystemValue('datadirectory').'/'.\OC_User::getUser()."/gallery".$path; + if (file_exists($thumbnail)) { + unlink($thumbnail); + } } private function __construct() {} From a4c47c674df2be3d32dcbb1e924986bc7df600ce Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Mon, 25 Jun 2012 11:55:51 +0200 Subject: [PATCH 23/48] write sql errors into the error log for better debugging --- lib/db.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/db.php b/lib/db.php index dc9e3392d0a..9e6835adc6f 100644 --- a/lib/db.php +++ b/lib/db.php @@ -246,6 +246,7 @@ class OC_DB { $entry = 'DB Error: "'.$result->getMessage().'"
    '; $entry .= 'Offending command was: '.$query.'
    '; OC_Log::write('core',$entry,OC_Log::FATAL); + error_log('DB error: '.$entry); die( $entry ); } }else{ @@ -255,6 +256,7 @@ class OC_DB { $entry = 'DB Error: "'.$e->getMessage().'"
    '; $entry .= 'Offending command was: '.$query.'
    '; OC_Log::write('core',$entry,OC_Log::FATAL); + error_log('DB error: '.$entry); die( $entry ); } $result=new PDOStatementWrapper($result); From a09a01a49fbbb7e821c0e9d259586930d51a87d5 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Mon, 25 Jun 2012 12:44:54 +0200 Subject: [PATCH 24/48] sanitizeHTML() has to be called later to keep the path unchanged --- apps/gallery/index.php | 2 +- apps/gallery/templates/index.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/gallery/index.php b/apps/gallery/index.php index 52a5b81a23a..b8aadacb47f 100644 --- a/apps/gallery/index.php +++ b/apps/gallery/index.php @@ -94,7 +94,7 @@ for($i = 0; $iassign('root', $root); +$tmpl->assign('root', $root, false); $tmpl->assign('tl', $tl, false); $tmpl->printPage(); ?> diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php index c3b4a178545..c90932cefd0 100644 --- a/apps/gallery/templates/index.php +++ b/apps/gallery/templates/index.php @@ -1,6 +1,6 @@