48 Commits

Author SHA1 Message Date
shadlaws
ea4622f726 #2022 - Fix handling of watermark dialog errors.
- admin_watermarks: changed header at end of form_add() from text/html to text/plain
- admin_watermarks: added header at end of form_edit() and form_delete() just like form_add() (currently omitted)
- admin_watermarks/gallery.dialog.js: removed unnecessary encode/decode workaround
2013-02-27 09:49:05 +01:00
shadlaws
fd0051dab7 #2006 - Add system::mark_file_for_delete API to delete files at shutdown.
- added system::mark_file_for_delete to be called to mark a file
- added system::delete_marked_files to be called at shutdown to delete the list
- amended system::temp_filename to, by default, add the temp name to the list
- updated a few other places in code where this should be used
2013-02-17 23:19:35 +01:00
shadlaws
d04a6fc87d #2001 - Make filename sanitizing more consistent.
- legal_file - added sanitize_filname() to sanitize photo/movie filenames.
- admin_watermarks - revised add() to use new function.
- item model - added _process_data_file_info() to validate the data file, get its metadata, and sanitize the item name.
- item model - revised save() for new items to use _process_data_file_info *before* the slug is checked.
- item model - revised save() for updated items to use _process_data_file_info.
- item model - revised save() for updated items to sanitize name if changed.
- uploader - removed call to smash_extensions (item model does this when it calls sanitize_filename).
- Legal_File_Helper_Test - added unit tests for sanitize_filename.
- Item_Model_Test - revised existing unit tests based on changes.
- Item_Model_Test - added new unit tests for names with legal but incorrect extensions.
- Averted take over by HAL with fix #2001...
2013-02-12 00:37:33 +01:00
shadlaws
0312d1b071 #1994 - Make get_file_metadata throw an exception if photo or movie is unidentifiable/illegal.
- photo & movie helpers: modified to throw exceptions when file is known to be unidentifiable/illegal.
- item model: revised to work with exceptions and be more explicit when the data file is invalid.
- item model: removed duplicate get_file_metadata call for updated items.
- admin_watermarks controller: revised to work with exceptions (really cleans up logic here).
- graphics helper: revised to handle invalid placeholders (a nearly-impossible corner case, but still...).
- photo & movie helper tests: revised to work with exceptions, added new tests for illegal files with valid extensions.
- item model tests: revised to work with exceptions, added new tests for illegal files with valid extensions.
2013-02-08 13:51:41 +01:00
shadlaws
8384d7948e Follow-on to 5fca371a61 for #1945.
Previously skipped admin_watermarks mods to use new functionality of #1945
since there was concurrent work on it with #1970.
Now that both are done, we can wrap this up.
2013-01-31 12:40:55 +01:00
Bharat Mediratta
9ef891858c Protect admins from themselves - in case an admin changed the
watermark.name setting to something terrible by accident via Admin >
Advanced, we'll just use the basename.  Fixes #1977.
2013-01-30 18:45:49 -05:00
shadlaws
4cf31d8850 #1970 - Make add watermarks more secure and add unit tests.
This follows #1855 and #1951...
- Ensured that invalid or illegal files are not added even if they have valid extensions.
- Added unit tests (currently there aren't any...)
2013-01-29 18:48:39 +01:00
shadlaws
212944e1ea #1951 - Make metadata generation more flexible (photo and movie helpers).
- added photo_get_file_metadata and movie_get_file_metadata events
- modified photo::get_file_metadata and movie::get_file_metadata to use them
- ensure that non-readable files throw exceptions
- redirected other photo metadata calls in core to photo::get_file_metadata (the helper function already exists, but in many places getimagesize is still called directly)
- added some unit tests (neither of the functions above had one)
2013-01-26 00:04:55 +01:00
Bharat Mediratta
d45a737779 Update copyright to 2013. Fixes #1953. 2013-01-21 01:22:01 -05:00
Bharat Mediratta
9e2ea2ffed Smash multiple extensions down into a single one when accepting file
uploads.  Fixes #1872.
2012-05-17 20:25:27 -07:00
Bharat Mediratta
fd4296c70f Inject some sanity into watermark file extensions. 2012-05-11 14:34:27 -07:00
Bharat Mediratta
bf2bb3e1ea Update copyright to 2012. #1822 2012-02-27 09:48:23 -08:00
Bharat Mediratta
423daa52d5 Update copyright to 2011. 2011-01-21 23:01:06 -08:00
Bharat Mediratta
9369fd55a3 Force the response type for uploaded watermarks to text/html.
// Override the application/json mime type.  The dialog based HTML uploader uses an iframe to
// buffer the reply, and on some browsers (Firefox 3.6) it does not know what to do with the
// JSON that it gets back so it puts up a dialog asking the user what to do with it.  So force
// the encoding type back to HTML for the iframe.
// See: http://jquery.malsup.com/form/#file-upload
2010-08-01 10:39:32 -07:00
Bharat Mediratta
7607e1f932 Full pass over all the JSON encoding and JS dialog code. We now abide
by the following rules:

1) An initial dialog or panel load can take either HTML or JSON, but
   the mime type must accurately reflect its payload.

2) dialog form submits can handle a pure HTML response, but the mime
   type must also be correct.  This properly resolves the problem
   where the reauth code gets a JSON response first from the reauth
   code, and then an HTML response when you reauth and continue on to
   a given form -- try it out with Admin > Settings > Advanced.

3) All JSON replies must set the mime type correctly.  The json::reply
   convenience function does this for us.

4) By default, any HTML content sent back in the JSON response should be
   in the "html" field, no longer the "form" field.

The combination of these allows us to stop doing boilerplate code like
this in our controllers:

  // Print our view, JSON encoded
  json::reply(array("form" => (string) $view));

instead, controllers can just return HTML, eg:

  // Print our view
  print $view;

That's much more intuitive for developers.
2010-07-31 21:16:17 -07:00
Tim Almdal
91a2c04a24 More patches as part of #1225. Change the 'core' modules to use the json::reply
method to set the content type header and encode the response as a json object
2010-07-31 15:44:55 -07:00
Tim Almdal
dbf3199e46 Fix for ticket #1181. Use $.getJSON to retrieve the json contents of the dialog. Convert all the controllers
that create the data to go into a dialog to return the html as part of a json object.
2010-07-06 14:12:01 -07:00
Tim Almdal
bb35aefffb Fix for ticket #797
When load a file is uploaded using a dialog box and the jquery plugin ajaxForm, the ajaxForm plugin uses an hidden iFrame element to send the multi-part
form and this is where the response goes.  The ajaxForm plugin then retrieves the document body and parses the result as a json string. If the file uploads
properly everything is fine, but if it fails Gallery3 return the input form with the the error fields highlighted as part of the json response. As this
response is returned to a hidden iframe, the browser attempts to manipulate it and all hell breaks loose. We lose the trailing brace, we start getting
escaping of form tags. When the ajaxForm plugin retrieves the iFrame body its no longer a valid json frame and the parsing fails and the user sees no
indication that it failed.
2010-06-11 12:36:23 -07:00
ckieffer
f1076590f1 Add page_title to admin views. Closes #1038. 2010-04-30 00:08:37 -06:00
Bharat Mediratta
c3c2b45280 Update the copyright to 2010. It's only 3 months into the year :-) 2010-03-03 10:15:34 -08:00
Bharat Mediratta
5c49c041e7 Use "(string) $form" instead of "$form->__toString()" 2010-01-16 22:42:02 -08:00
Tim Almdal
467b74c310 This path requires the upgrader to be run and applies the following changes:
* moves the composite method back into core
* requires that the operation be fully qualified i.e. gallery_graphics::resize
* caches the graphics rules on each request
2009-09-27 15:24:51 -07:00
Bharat Mediratta
43abcd9386 Security pass over all controller code. Mostly adding CSRF checking
and verifying user permissions, but there are several above-the-bar
changes:

1) Server add is now only available to admins.  This is a hard
   requirement because we have to limit server access (eg:
   server_add::children) to a user subset and the current permission
   model doesn't include that.  Easiest fix is to restrict to admins.
   Got rid of the server_add permission.

2) We now know check permissions at every level, which means in
   controllers AND in helpers.  This "belt and suspenders" approach will
   give us defense in depth in case we overlook it in one area.

3) We now do CSRF checking in every controller method that changes the
   code, in addition to the Forge auto-check.  Again, defense in depth
   and it makes scanning the code for security much simpler.

4) Moved Simple_Uploader_Controller::convert_filename_to_title to
   item:convert_filename_to_title

5) Fixed a bug in sending notification emails.

6) Fixed the Organize code to verify that you only have access to your
   own tasks.  In general, added permission checks to organize which had
   pretty much no validation code.

I did my best to verify every feature that I touched.
2009-06-01 22:40:22 -07:00
Bharat Mediratta
5495037a3d Gee it's May already. Update copyright to 2009. 2009-05-13 20:04:58 +00:00
Bharat Mediratta
847de44996 Fix the logical inversion of the transparency field. Now, 100% is max
transparency and 1% is min transparency (no transparency at all).

Fixes ticket #204.
2009-05-13 00:09:43 +00:00
Tim Almdal
9bba87ddc5 remove the extension and just use the IMAGETYPE_xxx constants 2009-02-24 01:24:11 +00:00
Tim Almdal
679b8c3971 Include jpg as valid graphic files 2009-02-23 14:45:09 +00:00
Bharat Mediratta
e83c2b3f8d Revert to using IMAGETYPE_XXX constants (at least for now) 2009-02-23 04:29:10 +00:00
Bharat Mediratta
2505bd1579 Hardcode extensions instead of using Image::$allowed_types because we
don't support TIFF files.  TIFF files are not viewable directly in
most browsers
2009-02-21 20:58:02 +00:00
Tim Almdal
af2f7f2c56 Use Image::$allowed_types instead of array(IMAGETYPE_GIF,
IMAGETYPE_JPEG, IMAGETYPE_PNG) as IMAGETYPE_GIF, IMAGETYPE_JPEG and
IMAGETYPE_PNG are not defined as constants
2009-02-20 19:04:58 +00:00
Andy Staudacher
a631fe29f3 i18n refactoring: Rename all _() (reserved by gettext) calls to t().
- And refactor printf to our string interpolation / pluralization syntax
- Also, a slight change to the translations_incomings table, using binary(16) instead of char(32) as message key.
2009-01-08 17:13:06 +00:00
Bharat Mediratta
6ab195854d Remove rest::JSON content type; it's causing lots of problems and it doesn't directly help since text/html works just as well for our JSON communications 2008-12-29 22:41:53 +00:00
Bharat Mediratta
776123496b Add transparency support 2008-12-29 22:30:19 +00:00
Bharat Mediratta
8102d8ea77 Clean up _update_graphics_rules() to make it more robust 2008-12-29 20:17:24 +00:00
Felix Rabinovich
6b1fa62173 Added content type to JSON output functions 2008-12-26 20:08:15 +00:00
Bharat Mediratta
ecf7d46a67 Add the graphics rules for both thumbs and resizes (instead of just thumbs). 2008-12-26 05:44:02 +00:00
Bharat Mediratta
dee20ed6a2 Added the concept of "permanent" messages that we show to admins. Use
this to show a "your thumbs/resizes are out of date" message whenever
we change the graphics rules.  Tweak watermark module to add graphics
rules whenever we make a change, which triggers the graphics module to
add the permanent message.
2008-12-26 05:43:06 +00:00
Bharat Mediratta
e31ca19a06 Added graphics::mark_all_dirty(). The watermark code now marks images
as dirty if the admin changes the watermark at all.
2008-12-26 04:52:18 +00:00
Bharat Mediratta
837a5430b8 More watermark changes:
Change admin/watermarks/upload -> admin/watermarks/add for consistency.

Internationalize position text, store it as text in the database,
display it to the admin.

Make i18n strings consistent to reduce l10n load.
2008-12-26 04:34:20 +00:00
Bharat Mediratta
2011ee13ef Remove an HTTP redirect that was breaking the Ajax interface. 2008-12-26 04:02:55 +00:00
Bharat Mediratta
0fc14c1bfc Simplify the watermark module. We can now upload, edit and delete one
watermark.  The UI is rough and we don't yet apply the watermark to
images.. that's next.
2008-12-26 01:32:12 +00:00
Bharat Mediratta
2c91a7e9ce Rework log and message helpers to be parallel, but separate.
1) they now have their own matching severity constants
2) they both have convenience functions success(), info(), warning() and error()
3) they both have severity_class()
2008-12-25 23:43:44 +00:00
Bharat Mediratta
94e3ae2e0f Add edit/delete links (they're just stubs now, but they open a dialog).
Add active/position to Watermark_Model
2008-12-25 22:31:20 +00:00
Bharat Mediratta
75b9a7872c Remove extra uniquifying text that Forge adds to uploaded files. 2008-12-25 21:54:09 +00:00
Bharat Mediratta
526ac39697 Remove stray response:: (not yet time for this.. it's coming!) 2008-12-24 04:25:11 +00:00
Bharat Mediratta
c7193f9b2e Normalize our Admin controllers so that functions always print out
their results, as opposed to having them return their view back
upstream.  This is a little more code in every controller, but it's
much less magical and more consistent.

Look up the active_theme and active_admin_theme inside the view
itself, no need to do that in the controllers.  This makes view
initialization easier in the controllers.
2008-12-24 04:22:22 +00:00
Bharat Mediratta
ddcf10dfce Allow the site admin to upload watermark images. Can't do much with them yet. 2008-12-23 01:29:17 +00:00
Bharat Mediratta
d330e4203a Step 1 of converting watermarks over to be an admin page. 2008-12-23 00:13:22 +00:00