I coded a piece of code, initially intended to act like an hack, that allow to rotate attachments images by adding a folder into phpBB root, a call to include a file, some js code added into overall_footer.html. All working like a charm, under the image link, when on post edit mode, appear a link Rotate which when clicked, open a popup: onclick into image, the image rotate, then you can click save to save in the position you like.
So nice, result is perfect. It's for gif (also trasparent), png and jpg (and easily can be improved with img ext of any kind)
The problem come out, when finished the required work, i like to release it like a free mod.
Beside the fact i should write a mod implementing all with classes etc (this is it? it is strictly required?) i followed another way instead, that work, and is really more short.
I do not need to write too much code to include these files, within a skeleton starting code, but when an ajax call is done by the popup, to a file that reside into a folder named core within the mod folder, and that receive the ajax request, to make it work and setup phpBB environment on it, i've start the code like this:
note:
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../../../../';
since i need the environment vars, i get all in this way: i define the root so any phpBB included file after, will work as expected
Code: Select all
define('IN_PHPBB', true);
// define the root from here
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../../../../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
// Thank you sun.
if (isset($_SERVER['CONTENT_TYPE']))
{
if ($_SERVER['CONTENT_TYPE'] === 'application/x-java-archive')
{
exit;
}
}
else if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Java') !== false)
{
exit;
}
///////////////////
// Obtain before common.php include, or will return error
///////////////////
if (isset($_POST['data'])){
$ajaxdata = json_decode(stripslashes($_POST['data']));
}
///////////////////
// implicit else: we are not in avatar mode
include($phpbb_root_path . 'common.' . $phpEx);
require($phpbb_root_path . 'includes/functions_download' . '.' . $phpEx);
.....
Questions:
I'm quite sure all this is secure, i can call this file making it work this way, isn't it?
Will be never validated, a mod that execute an ajax call this way?
Further help and/any consideration would be appreciated. Thank you
i will post all the mod code soon, asap it is "refined"
ADDED:
A new thread has been posted to support questions and report bugs here:
Attachments images rotation extension - devel/support thread
Please follow into the linked post, as suggested by mods.
I already answered and started into it about your question
phpBB attachments images rotation 1.0.3 on github