Skip to content

Commit dd31d22

Browse files
author
Craig Dietrich
committed
Roll back thumbnail upload on edit page, which seems to be the source of the random logouts
It uses a hidden iframe, which seems to be causing the session IDs to regenerated after 5 min…. so, another solution is needed.
1 parent 7e89afd commit dd31d22

File tree

6 files changed

+16
-20
lines changed

6 files changed

+16
-20
lines changed

system/application/libraries/MY_Session.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

system/application/models/login_model.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function get() {
4040
$result = $this->get_by_user_id($user_id);
4141
$result->is_logged_in = true;
4242
$result->error = null;
43+
$result->uri = $_SERVER['REQUEST_URI'];
4344
$this->session->set_userdata(array($this->login_basename => (array) $result));
4445
return (object) $data;
4546
}
@@ -49,6 +50,7 @@ public function get() {
4950
$data = new stdClass;
5051
$data->is_logged_in = false;
5152
$data->error = null;
53+
$data->uri = $_SERVER['REQUEST_URI'];
5254
$this->session->set_userdata(array($this->login_basename => (array) $data));
5355
return (object) $data;
5456

system/application/views/arbors/html5_RDFa/js/form-validation.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,16 @@ function validate_edit_form(form, no_action) {
191191

192192
var commit = function() {
193193
if (!check_fields()) return false;
194+
finish();
195+
// Don't use thumbnail upload, it seems to be the cause of the random logouts since it runs in an iframe
196+
/*
194197
var file_el = form.find('input[name="source_file"]');
195198
if (file_el.length && file_el.val().length) {
196199
form_file();
197200
} else {
198201
finish();
199202
};
203+
*/
200204
};
201205

202206
if ('source'==CKEDITOR.instances['sioc:content'].mode) { // If in source mode, switch to WYSIWYG to invoke formatting

system/application/views/melons/cantaloupe/edit.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@
211211
$(this).parents('#style-confirm,#script-confirm').data('confirmed',true).modal('hide');
212212
})
213213
// Taxonomies for title typeahead
214+
/*
214215
var fcroot = document.getElementById("approot").href.replace('/system/application/','');
215216
var book_slug = document.getElementById("parent").href.substring(fcroot.length);
216217
book_slug = book_slug.replace(/\//g,'');
@@ -240,6 +241,7 @@
240241
})
241242
$('#title').autocomplete({source:suggestions});
242243
});
244+
*/
243245
// Color Picker (in editor)
244246
if ($.isFunction($.fn.farbtastic)) {
245247
$('#colorpicker').farbtastic('#color_select');
@@ -411,7 +413,7 @@ function badges() {
411413
</div>
412414
</div>
413415
</div>
414-
<form id="edit_form" target="hidden_upload" action="<?=base_url().$book->slug.'/'?>upload_thumb" class="caption_font" method="post" enctype="multipart/form-data" onsubmit="return validate_edit_form($(this));">
416+
<form id="edit_form" class="caption_font" method="post" action="<?=base_url().$book->slug.'/'?>" onsubmit="validate_edit_form($(this));return false;">
415417
<input type="hidden" name="action" value="<?=(isset($page->version_index))?'update':'add'?>" />
416418
<input type="hidden" name="native" value="1" />
417419
<input type="hidden" name="scalar:urn" value="<?=(isset($page->version_index)) ? $page->versions[$page->version_index]->urn : ''?>" />
@@ -772,11 +774,13 @@ function badges() {
772774
}
773775
?></select>
774776
</div>
777+
<!--
775778
<div class="form-group">
776779
<label>Or upload a new thumbnail: &nbsp; <small>(JPG, PNG, or GIF format; will be resized to 120px)</small> &nbsp; <small><a href="javascript:void(null);" onclick="$('input[name=\'source_file\']').val('');return false;">clear selected file</a></small></label>
777780
<input type="file" name="source_file" />
778781
<div style="margin:0;padding:0;height:0;border:0;overflow:hidden;"><iframe id="hidden_upload" name="hidden_upload" src=""></iframe></div>
779782
</div>
783+
-->
780784
<div class="form-group">
781785
<label for="enter_thumbnail_url">Or enter any image URL:</label>
782786
<input id="enter_thumbnail_url" class="form-control" type="text" name="scalar:thumbnail" value="<?=@$page->thumbnail?>" />

system/application/views/melons/cantaloupe/js/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ $(window).ready(function() {
411411
// Scalar API
412412
{load: [base_uri+'/js/jquery.rdfquery.rules-1.0.js',
413413
base_uri+'/js/jquery.RDFa.js',
414-
base_uri+'/js/form-validation.js',
414+
base_uri+'/js/form-validation.js?v=2',
415415
widgets_uri+'/nav/jquery.scalarrecent.js',
416416
widgets_uri+'/cookie/jquery.cookie.js',
417417
widgets_uri+'/api/scalarapi.js'], complete:function() {

system/core/Input.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,10 @@ public function get_request_header($index, $xss_clean = FALSE)
845845
*/
846846
public function is_ajax_request()
847847
{
848-
return ($this->server('HTTP_X_REQUESTED_WITH') === 'XMLHttpRequest');
848+
if ( !isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest' ) {
849+
return false;
850+
}
851+
return true;
849852
}
850853

851854
// --------------------------------------------------------------------

0 commit comments

Comments
 (0)