Created
January 21, 2013 19:32
-
-
Save vdespa/4588583 to your computer and use it in GitHub Desktop.
Invalid token with Joomla custom component. http://stackoverflow.com/questions/14285536/invalid-token-with-joomla-custom-component/14433783#14433783
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @copyright This is free software released into the public domain. | |
* @license GNU General Public License version 2 or later; see http://www.gnu.org/licenses/gpl-2.0.html | |
* | |
* Created based on the information found on: | |
* | |
* http://stackoverflow.com/questions/14285536/invalid-token-with-joomla-custom-component/14433783#14433783 | |
* http://docs.joomla.org/How_to_add_CSRF_anti-spoofing_to_forms | |
* | |
* Copy this file inside components/com_recordings/ | |
*/ | |
defined('_JEXEC') or die; | |
class RecordingsController extends JControllerLegacy | |
{ | |
public function display($cachable = false, $urlparams = false) | |
{ | |
parent::display($cachable); | |
} | |
public function deletevideos() | |
{ | |
JRequest::checkToken('get') or die('Invalid Token'); | |
echo "Deleted!"; | |
die; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @copyright This is free software released into the public domain. | |
* @license GNU General Public License version 2 or later; see http://www.gnu.org/licenses/gpl-2.0.html | |
* | |
* Created based on the information found on: | |
* | |
* http://stackoverflow.com/questions/14285536/invalid-token-with-joomla-custom-component/14433783#14433783 | |
* http://docs.joomla.org/How_to_add_CSRF_anti-spoofing_to_forms | |
* Copy this file inside components/com_recordings/views/recordings/tmpl | |
*/ | |
?> | |
<a href="#" id="delete">Click here to delete</a> | |
<p id="message"></p> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> | |
<script> | |
$(document).ready(function(){ | |
$("#delete").click(function(e){ | |
e.preventDefault(); | |
jQuery.ajax({ | |
type: 'POST', | |
url: 'index.php?option=com_recordings&task=deletevideos&format=raw&<?php echo JUtility::getToken(); ?>=1', | |
success: function(data){ | |
$("#message").html("<b>" + data + "</b>"); | |
} | |
}); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment