View source
<?php
$current_dir = getcwd();
if (file_exists("../../../../../includes/bootstrap.inc")) {
chdir('../../../../../');
}
else {
if (file_exists("../../../../../../includes/bootstrap.inc")) {
chdir('../../../../../../');
}
else {
if (file_exists("../../../includes/bootstrap.inc")) {
chdir('../../../');
}
else {
print "Error: TinyBrowser module failed. Please refer to the README.txt.\n";
exit;
}
}
}
define('DRUPAL_ROOT', realpath(getcwd()));
include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
include_once DRUPAL_ROOT . '/includes/common.inc';
include_once DRUPAL_ROOT . '/includes/file.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$tinymce_root = tinybrowser_get_tinymce_root();
$editor = variable_get('tinybrowser_editor', 'tinymce');
$absolute_url = variable_get('tinybrowser_absolute_url', 0);
$upload_mode = variable_get('tinybrowser_upload_mode', 1);
$ok_ext_image = variable_get('tinybrowser_ok_ext_image', 'jpg jpeg gif png');
$ok_ext_media = variable_get('tinybrowser_ok_ext_media', 'swf dcr mov qt mpg mp3 mp4 mpeg avi wmv wm asf asx wmx wvx rm ra ram');
$ok_ext_file = variable_get('tinybrowser_ok_ext_file', '*');
$prohibited_ext = variable_get('tinybrowser_prohibited_ext', 'php php3 php4 phtml asp aspx ascx jsp cfm cfc pl bat exe dll reg cgi sh py asa asax config com inc');
$thumbnail_size = variable_get('tinybrowser_thumbnail_size', 80);
$default_view = variable_get('tinybrowser_default_view', 'thumb');
$default_sort = variable_get('tinybrowser_default_sort', 3);
$pagination = variable_get('tinybrowser_pagination', 0);
$popup_win_size = variable_get('tinybrowser_popup_window_size', '770x480');
$crop_win_size = variable_get('tinybrowser_max_crop_window_size', '770x480');
$drupal_root = getcwd();
$document_root = $_SERVER['DOCUMENT_ROOT'];
$drupal_root = str_replace($document_root, '', $drupal_root);
$file_directory_path = drupal_realpath('public://');
$file_directory_path = str_replace($document_root, '', $file_directory_path);
$jquery_path = $drupal_root . '/misc/jquery.js';
chdir($current_dir);
error_reporting(0);
set_time_limit(240);
$tinybrowser = array();
function tb_sanitize($input) {
if (is_array($input)) {
foreach ($input as $k => $i) {
$output[$k] = tb_sanitize($i);
}
}
else {
$input = htmlspecialchars($input, ENT_QUOTES);
if (get_magic_quotes_gpc()) {
$input = stripslashes($input);
}
$output = strip_tags($input);
}
return $output;
}
$_GET = tb_sanitize($_GET);
$_POST = tb_sanitize($_POST);
$_COOKIE = tb_sanitize($_COOKIE);
$_REQUEST = tb_sanitize($_REQUEST);
$sid = '';
if (isset($_COOKIE[session_name()])) {
$sid = $_COOKIE[session_name()];
}
if (isset($_GET['sessidpass'])) {
$sid = $_GET['sessidpass'];
}
if (!empty($sid)) {
session_id($sid);
$result = db_query("SELECT * from {sessions} WHERE sid = :sid", array(
':sid' => $sid,
));
if (!$result) {
watchdog('tinybrowser', 'Error: No such session ID - session has already expired or ended');
return FALSE;
}
$session = $result
->fetchObject();
if ($session->uid == 0) {
watchdog('tinybrowser', 'Error: Anonymous user can not use tinybrowser');
return FALSE;
}
$tinybrowser['uid'] = $session->uid;
}
else {
watchdog('tinybrowser', 'Error: Invalid direct access!');
return FALSE;
}
$user = user_load($tinybrowser['uid']);
$profile = tinybrowser_get_user_profile($user);
if (!$profile) {
watchdog('tinybrowser', 'No valid role profile is assigned for the user !name (ID=!uid)', array(
'!name' => $user->name,
'!uid' => $user->uid,
));
return FALSE;
}
$max_file_size = $profile['max_file_size'];
$max_image_size = $profile['max_image_size'];
$path_image = $profile['directory']['path_image'];
$path_media = $profile['directory']['path_media'];
$path_file = $profile['directory']['path_file'];
$quota = $profile['directory']['quota'];
$allow_upload = $profile['permissions']['upload'];
$allow_edit = $profile['permissions']['edit'];
$allow_delete = $profile['permissions']['delete'];
$allow_folders = $profile['permissions']['folders'];
$imagestyle = $profile['imagestyle'];
$path_image = str_replace("%u", $tinybrowser['uid'], $path_image);
$path_media = str_replace("%u", $tinybrowser['uid'], $path_media);
$path_file = str_replace("%u", $tinybrowser['uid'], $path_file);
$tinybrowser['sessioncheck'] = 'tinybrowser_module';
$_SESSION['tinybrowser_module'] = TRUE;
$tinybrowser['obfuscate'] = 's0merand0mjunk!!!111';
$tinybrowser['language'] = 'en';
$tinybrowser['integration'] = $editor;
$tinybrowser['docroot'] = rtrim($_SERVER['DOCUMENT_ROOT'], '/');
if ($_SERVER['SERVER_PORT'] == 443) {
$protocol = 'https://';
}
else {
$protocol = 'http://';
}
$tinybrowser['host'] = $protocol . $_SERVER['SERVER_NAME'];
$tinybrowser['unixpermissions'] = 0777;
$tinybrowser['path']['image'] = $path_image;
$tinybrowser['path']['media'] = $path_media;
$tinybrowser['path']['file'] = $path_file;
$tinybrowser['file_directory_path'] = $file_directory_path;
$tinybrowser['link']['image'] = $tinybrowser['path']['image'];
$tinybrowser['link']['media'] = $tinybrowser['path']['media'];
$tinybrowser['link']['file'] = $tinybrowser['path']['file'];
$tinybrowser['maxsize']['image'] = $max_file_size;
$tinybrowser['maxsize']['media'] = $max_file_size;
$tinybrowser['maxsize']['file'] = $max_file_size;
$tinybrowser['quota']['image'] = $quota;
$tinybrowser['quota']['media'] = $quota;
$tinybrowser['quota']['file'] = $quota;
$tinybrowser['imageresize']['width'] = 0;
$tinybrowser['imageresize']['height'] = 0;
if ($max_image_size != 0) {
$max_image_size = preg_replace('/\\s*/', '', $max_image_size);
$max_image_size = strtolower($max_image_size);
$max_size = split('x', $max_image_size);
$tinybrowser['imageresize']['width'] = intval($max_size[0]);
$tinybrowser['imageresize']['height'] = intval($max_size[1]);
}
$tinybrowser['thumbsrc'] = 'path';
$tinybrowser['thumbsize'] = intval($thumbnail_size);
$tinybrowser['imagequality'] = 95;
$tinybrowser['thumbquality'] = 95;
$tinybrowser['dateformat'] = 'd/m/Y H:i';
$tinybrowser['filetype']['image'] = preg_split('/\\s+/', $ok_ext_image);
$tinybrowser['filetype']['media'] = preg_split('/\\s+/', $ok_ext_media);
$tinybrowser['filetype']['file'] = preg_split('/\\s+/', $ok_ext_file);
$tinybrowser['prohibited'] = preg_split('/\\s+/', $prohibited_ext);
switch ($default_sort) {
case 0:
$tinybrowser['order']['by'] = 'name';
$tinybrowser['order']['type'] = 'asc';
break;
case 1:
$tinybrowser['order']['by'] = 'name';
$tinybrowser['order']['type'] = 'desc';
break;
case 2:
$tinybrowser['order']['by'] = 'modified';
$tinybrowser['order']['type'] = 'asc';
break;
case 3:
$tinybrowser['order']['by'] = 'modified';
$tinybrowser['order']['type'] = 'desc';
break;
default:
$tinybrowser['order']['by'] = 'name';
$tinybrowser['order']['type'] = 'asc';
break;
}
$tinybrowser['view']['image'] = $default_view;
$tinybrowser['pagination'] = intval($pagination);
$tinybrowser['upload_mode'] = intval($upload_mode);
$tinybrowser['absolute_url'] = intval($absolute_url);
$tinybrowser['tinymcecss'] = $tinymce_root . '/themes/advanced/skins/default/dialog.css';
$tinybrowser['tinymcepop'] = $tinymce_root . '/tiny_mce_popup.js';
$tinybrowser['jquery_path'] = $jquery_path;
$tinybrowser['context_path'] = $context_path;
$tinybrowser['jcrop_path'] = $jcrop_path;
$tinybrowser['fileupload_path'] = $fileupload_path;
$popup_win_size = preg_replace('/\\s*/', '', $popup_win_size);
$popup_win_size = strtolower($popup_win_size);
$win_size = split('x', $popup_win_size);
$tinybrowser['window']['width'] = intval($win_size[0]);
$tinybrowser['window']['height'] = intval($win_size[1]);
$crop_win_size = preg_replace('/\\s*/', '', $crop_win_size);
$crop_win_size = strtolower($crop_win_size);
$win_size = split('x', $crop_win_size);
$tinybrowser['crop_window']['width'] = intval($win_size[0]);
$tinybrowser['crop_window']['height'] = intval($win_size[1]);
$tinybrowser['allowupload'] = $allow_upload;
$tinybrowser['allowedit'] = $allow_edit;
$tinybrowser['allowdelete'] = $allow_delete;
$tinybrowser['allowfolders'] = $allow_folders;
$tinybrowser['imagestyle'] = $imagestyle;
$tinybrowser['cleanfilename'] = true;
if ($allow_delete) {
$tinybrowser['defaultaction'] = 'delete';
}
else {
$tinybrowser['defaultaction'] = 'rename';
}
$tinybrowser['delayprocess'] = 0;