Skip to content

Commit

Permalink
Roll back thumbnail upload on edit page, which seems to be the source…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
Craig Dietrich committed Sep 1, 2016
1 parent 7e89afd commit dd31d22
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 20 deletions.
17 changes: 0 additions & 17 deletions system/application/libraries/MY_Session.php

This file was deleted.

2 changes: 2 additions & 0 deletions system/application/models/login_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function get() {
$result = $this->get_by_user_id($user_id);
$result->is_logged_in = true;
$result->error = null;
$result->uri = $_SERVER['REQUEST_URI'];
$this->session->set_userdata(array($this->login_basename => (array) $result));
return (object) $data;
}
Expand All @@ -49,6 +50,7 @@ public function get() {
$data = new stdClass;
$data->is_logged_in = false;
$data->error = null;
$data->uri = $_SERVER['REQUEST_URI'];
$this->session->set_userdata(array($this->login_basename => (array) $data));
return (object) $data;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,16 @@ function validate_edit_form(form, no_action) {

var commit = function() {
if (!check_fields()) return false;
finish();
// Don't use thumbnail upload, it seems to be the cause of the random logouts since it runs in an iframe
/*
var file_el = form.find('input[name="source_file"]');
if (file_el.length && file_el.val().length) {
form_file();
} else {
finish();
};
*/
};

if ('source'==CKEDITOR.instances['sioc:content'].mode) { // If in source mode, switch to WYSIWYG to invoke formatting
Expand Down
6 changes: 5 additions & 1 deletion system/application/views/melons/cantaloupe/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@
$(this).parents('#style-confirm,#script-confirm').data('confirmed',true).modal('hide');
})
// Taxonomies for title typeahead
/*
var fcroot = document.getElementById("approot").href.replace('/system/application/','');
var book_slug = document.getElementById("parent").href.substring(fcroot.length);
book_slug = book_slug.replace(/\//g,'');
Expand Down Expand Up @@ -240,6 +241,7 @@
})
$('#title').autocomplete({source:suggestions});
});
*/
// Color Picker (in editor)
if ($.isFunction($.fn.farbtastic)) {
$('#colorpicker').farbtastic('#color_select');
Expand Down Expand Up @@ -411,7 +413,7 @@ function badges() {
</div>
</div>
</div>
<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));">
<form id="edit_form" class="caption_font" method="post" action="<?=base_url().$book->slug.'/'?>" onsubmit="validate_edit_form($(this));return false;">
<input type="hidden" name="action" value="<?=(isset($page->version_index))?'update':'add'?>" />
<input type="hidden" name="native" value="1" />
<input type="hidden" name="scalar:urn" value="<?=(isset($page->version_index)) ? $page->versions[$page->version_index]->urn : ''?>" />
Expand Down Expand Up @@ -772,11 +774,13 @@ function badges() {
}
?></select>
</div>
<!--
<div class="form-group">
<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>
<input type="file" name="source_file" />
<div style="margin:0;padding:0;height:0;border:0;overflow:hidden;"><iframe id="hidden_upload" name="hidden_upload" src=""></iframe></div>
</div>
-->
<div class="form-group">
<label for="enter_thumbnail_url">Or enter any image URL:</label>
<input id="enter_thumbnail_url" class="form-control" type="text" name="scalar:thumbnail" value="<?=@$page->thumbnail?>" />
Expand Down
2 changes: 1 addition & 1 deletion system/application/views/melons/cantaloupe/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ $(window).ready(function() {
// Scalar API
{load: [base_uri+'/js/jquery.rdfquery.rules-1.0.js',
base_uri+'/js/jquery.RDFa.js',
base_uri+'/js/form-validation.js',
base_uri+'/js/form-validation.js?v=2',
widgets_uri+'/nav/jquery.scalarrecent.js',
widgets_uri+'/cookie/jquery.cookie.js',
widgets_uri+'/api/scalarapi.js'], complete:function() {
Expand Down
5 changes: 4 additions & 1 deletion system/core/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,10 @@ public function get_request_header($index, $xss_clean = FALSE)
*/
public function is_ajax_request()
{
return ($this->server('HTTP_X_REQUESTED_WITH') === 'XMLHttpRequest');
if ( !isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest' ) {
return false;
}
return true;
}

// --------------------------------------------------------------------
Expand Down

0 comments on commit dd31d22

Please sign in to comment.