.
*/
//ini_set( 'include_path', dirname( __FILE__ ) . '/inc/Dropbox/pear_includes' . PATH_SEPARATOR . ini_get('include_path') );
//set_include_path( get_include_path() . PATH_SEPARATOR . dirname( __FILE__ ) . '/inc/Dropbox/pear_includes' );
$disabled_functions = str_replace(" ","",ini_get( 'disable_functions' ));
$wpdb_include_path_ini = dirname( __FILE__ ) . '/inc/Dropbox/pear_includes' . PATH_SEPARATOR . ini_get('include_path');
$wpdb_include_path_set = get_include_path() . PATH_SEPARATOR . dirname( __FILE__ ) . '/inc/Dropbox/pear_includes';
//print_r($disabled_functions);
//echo ini_get('include_path').'
';
//echo get_include_path();
if (!class_exists('HTTP_OAuth_Consumer') && !class_exists('OAuth')) {
if ( $disabled_functions != '' ) {
$disabled_functions_array = explode( ',', $disabled_functions );
if (true === in_array( 'ini_set', $disabled_functions_array )) {
if ((true === in_array( 'set_include_path', $disabled_functions_array )) || set_include_path($wpdb_include_path_set) == false) {
?>
';
$showform = True;
try {
if ($db_allow_ext == '')
throw new Exception(__('Need to configure allowed file extensions!',simpleDbUpload));
if ((get_option('db_auth_step') < 3) or ($db_key == '') or ($db_secret == '') or ($db_token == '') or ($db_token_secret == '') )
throw new Exception(__('Need to authorize plugin!',simpleDbUpload));
} catch(Exception $e) {
echo '
'.__('Error:',simpleDbUpload). ' ' . htmlspecialchars($e->getMessage()) . '';
$showform = False;
}
if ($_POST['gogogadget']) {
try {
include 'inc/Dropbox/autoload.php';
if (class_exists('HTTP_OAuth_Consumer')){
$oauth = new Dropbox_OAuth_PHP($db_key, $db_secret);
}else{
$oauth = new Dropbox_OAuth_PEAR($db_key, $db_secret);
}
//$oauth = new Dropbox_OAuth_Wordpress($db_key, $db_secret);
$oauth->setToken($db_token,$db_token_secret);
$dropbox = new Dropbox_API($oauth);
} catch(Exception $e) {
echo '
'.__('Error:',simpleDbUpload). ' ' . htmlspecialchars($e->getMessage()) . '';
$showform = False;
}
try {
$allowedExtensions = split("[ ]+", $db_allow_ext);
foreach ($_FILES as $file) {
if ($file['tmp_name'] > '') {
$file['name'] = str_replace(' ', '%20', $file['name']);
if (!in_array(end(explode(".", strtolower($file['name']))), $allowedExtensions)) {
$ext = implode(", ", $allowedExtensions);
throw new Exception(__('Allowed file extensions: ',simpleDbUpload).''.$ext);
//break;
//die('
'.__('Allowed file extensions: ',simpleDbUpload).''.$ext.'
'. ''. __('<= Go back',simpleDbUpload).'
');
}
}
}
// Rename uploaded file to reflect original name
if ($_FILES['file']['error'] !== UPLOAD_ERR_OK)
throw new Exception(__('File was not uploaded from your computer.',simpleDbUpload));
if (!file_exists($db_tmp_path))
{
if (!mkdir($db_tmp_path))
throw new Exception(__('Cannot create temporary directory!',simpleDbUpload));
}
if ($_FILES['file']['name'] === "")
throw new Exception(__('File name not supplied by the browser.',simpleDbUpload));
//$new_file_name = str_replace(' ', '_', $new_file_name);
$new_file_name = explode(".",$file['name']);
$tmpFile = $db_tmp_path.'/'.str_replace("/\0", '_', $new_file_name[0]) . "_" . date("Y-m-d").".".str_replace("/\0", '_', $new_file_name[1]);
if (!move_uploaded_file($_FILES['file']['tmp_name'], $tmpFile))
throw new Exception(__('Cannot rename uploaded file!',simpleDbUpload));
// Upload
$chunks = explode("/",$tmpFile);
for($i = 0; $i < count($chunks); $i++){
$c = $i;
}
if ( !$dropbox->putFile(trim($dp_path,'/').'/'.$chunks[$c], $tmpFile,"dropbox") ) {
throw new Exception(__('ERROR! Upload Failed.',simpleDbUpload));
}
//echo '
'.__('Your file is uploaded',simpleDbUpload).'';
echo '
'.$db_thank_message.'';
if($db_show_form == "True"){
$showform = True;
}else{
$showform = False;
}
if($db_delete_file == "True"){
$delete_file = True;
}else{
$delete_file = False;
}
} catch(Exception $e) {
echo '
'.__('Error: ',simpleDbUpload) . ' ' . html_entity_decode($e->getMessage()) . '';
$showform = True;
$delete_file = True;
}
// Clean up
if($delete_file == True) {
if (isset($tmpFile) && file_exists($tmpFile))
unlink($tmpFile);
}
}
if($showform == True) {?>
";
}
function wp_dropbox_settings_page() {
if(isset($_POST['db_cancel'])){
update_option('db_auth_step',1);
update_option( 'db_auth_token', "");
update_option( 'db_auth_token_secret', "");
}
?>