}
                }
                $limit += $limit_step;
                flush();
                sleep(2);
            } while ($count > 0);
            $output .= '</channel>' . "\n";
            $output .= '</rss>' . "\n";
            if (file_exists(OOS_FEEDS_EXPORT_PATH . $file_google)) {
                unlink(OOS_FEEDS_EXPORT_PATH . $file_google);
            }
            $fp = fopen(OOS_FEEDS_EXPORT_PATH . $file_google, "w");
            $fout = fwrite($fp, $output);
            fclose($fp);
            if (!$dryrun) {
                $result = ftp_file($ftp_server, $ftp_user_name, $ftp_password, OOS_FEEDS_EXPORT_PATH . $file_google, $ftp_directory, $ftp_destination_file);
            }
            $messageStack->add(SUCCESS_EXPORT_DATABASE_SAVED, 'success');
            break;
        case 'deleteconfirm':
            if (strstr($_GET['file'], '..')) {
                oos_redirect_admin(oos_href_link_admin($aFilename['export_googlebase']));
            }
            oos_remove(OOS_FEEDS_EXPORT_PATH . '/' . $_GET['file']);
            if (!$oos_remove_error) {
                $messageStack->add_session(SUCCESS_EXPORT_DELETED, 'success');
                oos_redirect_admin(oos_href_link_admin($aFilename['export_googlebase']));
            }
            break;
    }
}
function create_thumbnail($source, $new_file, $mimetype)
{
    global $attach_config, $imagick;
    $source = amod_realpath($source);
    $min_filesize = intval($attach_config['img_min_thumb_filesize']);
    $img_filesize = @file_exists(@amod_realpath($source)) ? filesize($source) : false;
    if (!$img_filesize || $img_filesize <= $min_filesize) {
        return FALSE;
    }
    $size = image_getdimension($source);
    if ($size[0] == 0 && $size[1] == 0) {
        return FALSE;
    }
    $new_size = get_img_size_format($size[0], $size[1]);
    $tmp_path = '';
    $old_file = '';
    if (intval($attach_config['allow_ftp_upload'])) {
        $old_file = $new_file;
        $tmp_path = explode('/', $source);
        $tmp_path[count($tmp_path) - 1] = '';
        $tmp_path = implode('/', $tmp_path);
        if ($tmp_path == '') {
            $tmp_path = '/tmp';
        }
        $value = trim($tmp_path);
        if ($value[strlen($value) - 1] == '/') {
            $value[strlen($value) - 1] = ' ';
        }
        $new_file = trim($value) . '/t00000';
    }
    $used_imagick = FALSE;
    if (is_imagick()) {
        if (is_array($size) && count($size) > 0) {
            passthru($imagick . ' -quality 85 -antialias -sample ' . $new_size[0] . 'x' . $new_size[1] . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $new_file) . '"');
            if (@file_exists(@amod_realpath($new_file))) {
                $used_imagick = TRUE;
            }
        }
    }
    if (!$used_imagick) {
        $type = $size[2];
        $supported_types = get_supported_image_types();
        if (in_array($type, $supported_types)) {
            switch ($type) {
                case '1':
                    $im = imagecreatefromgif($source);
                    $new_im = imagecreate($new_size[0], $new_size[1]);
                    imagecopyresized($new_im, $im, 0, 0, 0, 0, $new_size[0], $new_size[1], $size[0], $size[1]);
                    imagegif($new_im, $new_file);
                    break;
                case '2':
                    $im = imagecreatefromjpeg($source);
                    $new_im = intval($attach_config['use_gd2']) ? @imagecreatetruecolor($new_size[0], $new_size[1]) : imagecreate($new_size[0], $new_size[1]);
                    imagecopyresized($new_im, $im, 0, 0, 0, 0, $new_size[0], $new_size[1], $size[0], $size[1]);
                    imagejpeg($new_im, $new_file, 90);
                    break;
                case '3':
                    $im = imagecreatefrompng($source);
                    $new_im = intval($attach_config['use_gd2']) ? @imagecreatetruecolor($new_size[0], $new_size[1]) : imagecreate($new_size[0], $new_size[1]);
                    imagecopyresized($new_im, $im, 0, 0, 0, 0, $new_size[0], $new_size[1], $size[0], $size[1]);
                    imagepng($new_im, $new_file);
                    break;
            }
        }
    }
    if (!@file_exists(@amod_realpath($new_file))) {
        return FALSE;
    }
    if (intval($attach_config['allow_ftp_upload'])) {
        $result = ftp_file($new_file, $old_file, $this->type, TRUE);
        // True for disable error-mode
        if (!$result) {
            return FALSE;
        }
    } else {
        @chmod($new_file, 0664);
    }
    return TRUE;
}
/**
* Create thumbnail
*/
function create_thumbnail($source, $new_file, $mimetype)
{
    global $attach_config, $imagick;
    $source = amod_realpath($source);
    $min_filesize = (int) $attach_config['img_min_thumb_filesize'];
    $img_filesize = @file_exists($source) ? @filesize($source) : false;
    if (!$img_filesize || $img_filesize <= $min_filesize) {
        return false;
    }
    list($width, $height, $type, ) = getimagesize($source);
    if (!$width || !$height) {
        return false;
    }
    list($new_width, $new_height) = get_img_size_format($width, $height);
    $tmp_path = $old_file = '';
    if (intval($attach_config['allow_ftp_upload'])) {
        $old_file = $new_file;
        $tmp_path = explode('/', $source);
        $tmp_path[count($tmp_path) - 1] = '';
        $tmp_path = implode('/', $tmp_path);
        if ($tmp_path == '') {
            $tmp_path = '/tmp';
        }
        $value = trim($tmp_path);
        if ($value[strlen($value) - 1] == '/') {
            $value[strlen($value) - 1] = ' ';
        }
        //
        $new_file = tempnam(trim($value), 't00000');
        // We remove it now because it gets created again later
        @unlink($new_file);
    }
    $used_imagick = false;
    if (is_imagick()) {
        passthru($imagick . ' -quality 85 -antialias -sample ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $new_file) . '"');
        if (@file_exists($new_file)) {
            $used_imagick = true;
        }
    }
    if (!$used_imagick) {
        $type = get_supported_image_types($type);
        if ($type['gd']) {
            switch ($type['format']) {
                case IMG_GIF:
                    $image = imagecreatefromgif($source);
                    break;
                case IMG_JPG:
                    $image = imagecreatefromjpeg($source);
                    break;
                case IMG_PNG:
                    $image = imagecreatefrompng($source);
                    break;
                case IMG_WBMP:
                    $image = imagecreatefromwbmp($source);
                    break;
            }
            if ($type['version'] == 1 || !$attach_config['use_gd2']) {
                $new_image = imagecreate($new_width, $new_height);
                imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
            } else {
                $new_image = imagecreatetruecolor($new_width, $new_height);
                imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
            }
            switch ($type['format']) {
                case IMG_GIF:
                    imagegif($new_image, $new_file);
                    break;
                case IMG_JPG:
                    imagejpeg($new_image, $new_file, 90);
                    break;
                case IMG_PNG:
                    imagepng($new_image, $new_file);
                    break;
                case IMG_WBMP:
                    imagewbmp($new_image, $new_file);
                    break;
            }
            imagedestroy($new_image);
        }
    }
    if (!@file_exists($new_file)) {
        return false;
    }
    if (intval($attach_config['allow_ftp_upload'])) {
        $result = ftp_file($new_file, $old_file, $mimetype, true);
        // True for disable error-mode
        @unlink($new_file);
        if (!$result) {
            return false;
        }
    } else {
        @chmod($new_file, 0664);
    }
    return true;
}
 function move_uploaded_attachment($upload_mode, $file)
 {
     global $error, $error_msg, $lang, $upload_dir;
     if (!is_uploaded_file($file)) {
         message_die(GENERAL_ERROR, 'Unable to upload file. The given source has not been uploaded.', __LINE__, __FILE__);
     }
     switch ($upload_mode) {
         case 'copy':
             if (!@copy($file, $upload_dir . '/' . basename($this->attach_filename))) {
                 if (!@move_uploaded_file($file, $upload_dir . '/' . basename($this->attach_filename))) {
                     $error = TRUE;
                     if (!empty($error_msg)) {
                         $error_msg .= '<br />';
                     }
                     $error_msg .= sprintf($lang['General_upload_error'], './' . $upload_dir . '/' . $this->attach_filename);
                     return;
                 }
             }
             @chmod($upload_dir . '/' . basename($this->attach_filename), 0666);
             break;
         case 'move':
             if (!@move_uploaded_file($file, $upload_dir . '/' . basename($this->attach_filename))) {
                 if (!@copy($file, $upload_dir . '/' . basename($this->attach_filename))) {
                     $error = TRUE;
                     if (!empty($error_msg)) {
                         $error_msg .= '<br />';
                     }
                     $error_msg .= sprintf($lang['General_upload_error'], './' . $upload_dir . '/' . $this->attach_filename);
                     return;
                 }
             }
             @chmod($upload_dir . '/' . $this->attach_filename, 0666);
             break;
         case 'ftp':
             ftp_file($file, basename($this->attach_filename), $this->type);
             break;
     }
     if (!$error && $this->thumbnail == 1) {
         if ($upload_mode == 'ftp') {
             $source = $file;
             $dest_file = THUMB_DIR . '/t_' . basename($this->attach_filename);
         } else {
             $source = $upload_dir . '/' . basename($this->attach_filename);
             $dest_file = amod_realpath($upload_dir);
             $dest_file .= '/' . THUMB_DIR . '/t_' . basename($this->attach_filename);
         }
         if (!create_thumbnail($source, $dest_file, $this->type)) {
             if (!$file || !create_thumbnail($file, $dest_file, $this->type)) {
                 $this->thumbnail = 0;
             }
         }
     }
 }
 function move_uploaded_attachment($upload_mode, $file)
 {
     global $error, $error_msg, $lang, $upload_dir;
     if (!is_uploaded_file($file)) {
         message_die(GENERAL_ERROR, 'Unable to upload file. The given source has not been uploaded.', __LINE__, __FILE__);
     }
     switch ($upload_mode) {
         case 'copy':
             /*
             				$ini_val = ( phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var';
             
             				$tmp_path = ( !@$ini_val('safe_mode') ) ? '' : $upload_dir . '/tmp';
             
             				if ($tmp_path != '')
             				{
             					$tmp_filename = tempnam($tmp_path, 't0000');
             
             					$fd = fopen($file, 'r');
             					$data = fread ($fd, $this->filesize);
             					fclose ($fd);
             
             					$fptr = @fopen($tmp_filename, 'wb');
             					$bytes_written = @fwrite($fptr, $data, $this->filesize);
             					@fclose($fptr);
             					$file = $tmp_filename;
             				}
             */
             if (!@copy($file, $upload_dir . '/' . $this->attach_filename)) {
                 if (!@move_uploaded_file($file, $upload_dir . '/' . $this->attach_filename)) {
                     $error = TRUE;
                     if (!empty($error_msg)) {
                         $error_msg .= '<br />';
                     }
                     $error_msg .= sprintf($lang['General_upload_error'], './' . $upload_dir . '/' . $this->attach_filename);
                     return;
                 }
             }
             @chmod($upload_dir . '/' . $this->attach_filename, 0666);
             break;
         case 'move':
             if (!@move_uploaded_file($file, $upload_dir . '/' . $this->attach_filename)) {
                 if (!@copy($file, $upload_dir . '/' . $this->attach_filename)) {
                     $error = TRUE;
                     if (!empty($error_msg)) {
                         $error_msg .= '<br />';
                     }
                     $error_msg .= sprintf($lang['General_upload_error'], './' . $upload_dir . '/' . $this->attach_filename);
                     return;
                 }
             }
             @chmod($upload_dir . '/' . $this->attach_filename, 0666);
             /*				if ($tmp_path != '')
             				{
             					unlink_attach($file);
             				}*/
             break;
         case 'ftp':
             ftp_file($file, $this->attach_filename, $this->type);
             break;
     }
     if (!$error && $this->thumbnail == 1) {
         if ($upload_mode == 'ftp') {
             $source = $file;
             $dest_file = THUMB_DIR . '/t_' . $this->attach_filename;
         } else {
             $source = $upload_dir . '/' . $this->attach_filename;
             $dest_file = amod_realpath($upload_dir);
             $dest_file .= '/' . THUMB_DIR . '/t_' . $this->attach_filename;
         }
         if (!create_thumbnail($source, $dest_file, $this->type)) {
             if (!$file || !create_thumbnail($file, $dest_file, $this->type)) {
                 $this->thumbnail = 0;
             }
         }
     }
 }
 private function move_uploaded_attachment($file, $filename)
 {
     global $error, $error_msg, $lang, $upload_dir, $attach_config;
     if (intval($attach_config['allow_ftp_upload'])) {
         ftp_file($filename, $this->attach_filename, $this->type);
     } else {
         require_once 'includes/classes/cpg_file.php';
         if (!CPG_File::move_upload($file, $upload_dir . '/' . $this->attach_filename)) {
             $error = TRUE;
             if (!empty($error_msg)) {
                 $error_msg .= '<br />';
             }
             $error_msg .= sprintf($lang['General_upload_error'], './' . $upload_dir . '/' . $this->attach_filename);
             return;
         }
     }
     if (!$error && $this->thumbnail == 1) {
         if (intval($attach_config['allow_ftp_upload'])) {
             $source = $file;
             $dest_file = THUMB_DIR . '/t_' . $this->attach_filename;
         } else {
             $source = $upload_dir . '/' . $this->attach_filename;
             $dest_file = amod_realpath($upload_dir);
             $dest_file .= '/' . THUMB_DIR . '/t_' . $this->attach_filename;
         }
         if (!create_thumbnail($file, $dest_file, $this->type)) {
             if (!create_thumbnail($source, $dest_file, $this->type)) {
                 $this->thumbnail = 0;
             }
         }
     }
 }
Beispiel #7
0
function create_thumbnail($source, $new_file)
{
    global $attach_config;
    $source = amod_realpath($source);
    $min_filesize = intval($attach_config['img_min_thumb_filesize']);
    $img_filesize = file_exists(amod_realpath($source)) ? filesize($source) : false;
    if (!$img_filesize || $img_filesize <= $min_filesize) {
        return FALSE;
    }
    $size = image_getdimension($source);
    if ($size[0] <= 0 && $size[1] <= 0) {
        return FALSE;
    }
    $new_size = get_img_size_format($size[0], $size[1]);
    $tmp_path = '';
    $old_file = '';
    if (intval($attach_config['allow_ftp_upload'])) {
        $old_file = $new_file;
        $tmp_path = explode('/', $source);
        $tmp_path[count($tmp_path) - 1] = '';
        $tmp_path = implode('/', $tmp_path);
        if ($tmp_path == '') {
            $tmp_path = '/tmp';
        }
        $value = trim($tmp_path);
        if ($value[strlen($value) - 1] == '/') {
            $value[strlen($value) - 1] = ' ';
        }
        $new_file = trim($value) . '/t00000';
    }
    global $MAIN_CFG;
    if (!isset($MAIN_CFG['imaging']['type'])) {
        //$attach_config['use_gd2']
        $MAIN_CFG['imaging']['type'] = empty($attach_config['img_imagick']) ? 'gd2' : 'im';
        $MAIN_CFG['imaging']['impath'] = $attach_config['img_imagick'];
        $MAIN_CFG['imaging']['pbmpath'] = $attach_config['img_imagick'];
    }
    require_once 'includes/imaging/imaging.inc';
    Graphic::resize($source, $new_size, $new_file, $size);
    if (!file_exists(amod_realpath($new_file))) {
        return FALSE;
    }
    if (intval($attach_config['allow_ftp_upload'])) {
        $result = ftp_file($new_file, $old_file, $this->type, TRUE);
        // True for disable error-mode
        if (!$result) {
            return FALSE;
        }
    } else {
        chmod($new_file, PHP_AS_NOBODY ? 0666 : 0644);
    }
    return TRUE;
}