Esempio n. 1
0
            // This is a directory, so we move on.
            continue;
        }
        // We find out when the file was last accessed.
        $access_time = filemtime($dir_path);
        // fileatime() returned incorrect value on Windows
        // We find out the current time.
        $current_time = time();
        // We calculate the the delete time. We will delete anything older than $cache_time.
        $delete_time = $current_time - $access_time;
        // Now we compare the two.
        if ($delete_time >= $cache_time) {
            // The file is old. We delete it.
            $deleted_list[] = $dir_path;
            // Store the name of the file getting deleted
            unlink($dir_path);
        }
    }
    // Don't forget to close the directory.
    closedir($directory_handle);
    // For logging purposes
    if ($CONFIG['log_mode']) {
        for ($i = 0; $i < count($deleted_list); $i++) {
            log_write('Garbage collection deleted ' . $deleted_list[$i] . ' at ' . date("F j, Y, g:i a"), CPG_GLOBAL_LOG);
        }
    }
    return $deleted_list;
}
if ($CONFIG['log_mode']) {
    spring_cleaning('logs', CPG_DAY * 2, array('log_header.inc.php'));
}
}
// Retrieve DB stored configuration
$result = cpg_db_query("SELECT name, value FROM {$CONFIG['TABLE_CONFIG']}");
while ($row = mysql_fetch_assoc($result)) {
    $CONFIG[$row['name']] = $row['value'];
}
// while
mysql_free_result($result);
// Check if Coppermine is allowed to store cookies (cookie consent is required and user has agreed to store cookies)
define('CPG_COOKIES_ALLOWED', $CONFIG['cookies_need_consent'] && !$superCage->cookie->keyExists($CONFIG['cookie_name'] . '_cookies_allowed') ? false : true);
// A space cannot be stored in the config table since the value field is VARCHAR, so %20 is used instead.
if ($CONFIG['keyword_separator'] == '%20') {
    $CONFIG['keyword_separator'] = ' ';
}
if ($CONFIG['log_mode']) {
    spring_cleaning('logs', $CONFIG['log_retention'] > 0 ? $CONFIG['log_retention'] : CPG_DAY * 2, array('log_header.inc.php'));
}
// Record User's IP address
$raw_ip = $superCage->server->testIp('REMOTE_ADDR') ? $superCage->server->getEscaped('REMOTE_ADDR') : '0.0.0.0';
if ($superCage->server->testIp('HTTP_CLIENT_IP')) {
    $hdr_ip = $superCage->server->getEscaped('HTTP_CLIENT_IP');
} else {
    if ($superCage->server->testIp('HTTP_X_FORWARDED_FOR')) {
        $hdr_ip = $superCage->server->getEscaped('X_FORWARDED_FOR');
    } else {
        $hdr_ip = $raw_ip;
    }
}
// Reference 'site_url' to 'ecards_more_pic_target'
$CONFIG['site_url'] =& $CONFIG['ecards_more_pic_target'];
// Set the site_url in js_vars so that it can be used in js
            <td align="center" class="tableb">
          {$lang_errors['perm_denied']}
          </td>
    </tr>
EOT;
    endtable();
    pagefooter();
} else {
    // zipdownload allowed, go ahead...
    $filelist = array();
    if (count($FAVPICS) > 0) {
        if ($CONFIG['enable_zipdownload'] == 2) {
            $params = array('{GAL_NAME}' => $CONFIG['gallery_name'], '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'], '{GAL_URL}' => $CONFIG['ecards_more_pic_target'] . 'thumbnails.php?album=favpics', '{USERNAME}' => sprintf($lang_thumb_view['zipdownload_username'], USER_NAME), '{DATE}' => localised_date(-1, $lang_date['comment']), '{COPYRIGHTS}' => $lang_thumb_view['zipdownload_copyright']);
            $plaintext_message = template_eval($template_zipfile_plaintext, $params);
            // Garbage collection: get rid of existing readme file
            spring_cleaning('./' . $CONFIG['fullpath'] . 'edit', CPG_HOUR);
            // Create a unique file name
            $readme_filename = 'readme_' . time() . '.txt';
            // Create the temporary readme file
            if ($fd = @fopen($CONFIG['fullpath'] . 'edit/' . $readme_filename, 'wb')) {
                @fwrite($fd, $plaintext_message);
                @fclose($fd);
                // Add the plain text file to the file list
                $filelist[] = 'edit/' . $readme_filename;
            } else {
                // Something went wrong while creating the readme file.
                // We'll continue anyway.
            }
        }
        $favs = implode(', ', $FAVPICS);
        $result = cpg_db_query("SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' AND pid IN ({$favs})");
    pagefooter();
}
//------------------------------MAIN CODE BLOCK---------------------------
// Check to see if the uploader has permission to upload. close the script if he doesn't.
if (!USER_CAN_UPLOAD_PICTURES) {
    cpg_die(ERROR, $lang_errors['perm_denied'], __FILE__, __LINE__);
}
// Let us define the directories where images will be temporarily stored.
$transitory_file_directory = "./albums/manipulation/transitory/";
$preview_image_directory = "./albums/manipulation/transitory/previews/";
// We can also create a rudimentary language array to make integration into CPG easier at a later date.
$lang_image_processor_php = array('finished_manipulation' => 'You have finished manipulating the image. Please click the Proceed button to finish uploading the image.', 'finished_manipulation_button' => 'Proceed', 'page_title' => 'Image Manipulation', 'preview_image_alt_text' => 'Thumbnail preview of image.', 'manipulation_query' => 'This is how the image you selected for upload currently appears. Do you wish to rotate the image? All rotations are counterclockwise. Please note, your image has not been uploaded yet.', 'no_manipulation' => 'No', 'IM_Error' => 'Error executing ImageMagick - Return value: ', 'cmd_line' => 'Command Line :', 'mog_said' => 'The mogrify program said:', 'file_corrupt' => 'The file is corrupt or not accessible.', 'no_write' => 'Could not write image to disk.', 'GD_GIF_Warning' => 'The image you submitted is in GIF format. Unfortunately, GIF images use the Unisys patented LZW compression scheme, so this program cannot work with them. Please convert your image to PNG or JPG. Then try uploading it again.', 'not_supported' => 'The uploaded image type is not supported. Please upload JPG or PNG images.', 'no_open_trans_dir' => 'Could not open transitory directory.', 'no_move' => 'Couldn\'t copy', 'bad_angle' => 'The angle submitted is unacceptable. Please try again.', 'tampering' => 'The preview image is missing or its path has been altered.', 'primary_tampering' => 'The primary image path is not valid, or the file does not exist.', 'err_invalid_fext' => 'Your file extension is not valid.');
// Let's inspect the directories for old files, and delete them if they are too old.
// Old files might appear if a user upload was interrupted.
spring_cleaning($transitory_file_directory);
spring_cleaning($preview_image_directory);
// The directories have been tidied.
// We also need to set the preview thumbnail width.
$maximum_width = $CONFIG['thumb_width'];
// First, we test for the variable $degrees to determine script action.
if (!isset($HTTP_POST_VARS['degrees'])) {
    // Display initial form.
    // First, we must capture all the data sent to us by upload.php.
    $event = $HTTP_POST_VARS['event'];
    $album = (int) $HTTP_POST_VARS['album'];
    $title = $HTTP_POST_VARS['title'];
    $caption = $HTTP_POST_VARS['caption'];
    $keywords = $HTTP_POST_VARS['keywords'];
    $user1 = $HTTP_POST_VARS['user1'];
    $user2 = $HTTP_POST_VARS['user2'];
    $user3 = $HTTP_POST_VARS['user3'];
Esempio n. 5
0
function download_resized_add_data($pic_data)
{
    global $CONFIG, $album;
    $superCage = Inspekt::makeSuperCage();
    $lang = isset($USER['lang']) ? $USER['lang'] : $CONFIG['lang'];
    if (!file_exists("plugins/download_resized/lang/{$lang}.php")) {
        $lang = 'english';
    }
    require "plugins/download_resized/lang/{$lang}.php";
    $sizes = array();
    $sizes[0]['x'] = '1600';
    $sizes[1]['x'] = '1440';
    $sizes[2]['x'] = '1280';
    $sizes[3]['x'] = '1024';
    $sizes[4]['x'] = '800';
    $sizes[5]['x'] = '640';
    $sizes[6]['x'] = $CONFIG['picture_width'];
    $mime_content_image = cpg_get_type(get_pic_url($pic_data, 'fullsize'));
    if ($superCage->post->keyExists('resize_pid')) {
        $pid = $superCage->post->getInt('resize_pid');
        $size = $superCage->post->getInt('resize_id');
        //sanitize data
        if (!is_numeric($size)) {
            cpg_die(ERROR, 'Data not valid', __FILE__, __LINE__);
        }
        $result = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} WHERE pid = '{$pid}'");
        $row = mysql_fetch_assoc($result);
        if ($row) {
            $path = $CONFIG['fullpath'] . $row['filepath'];
            if (isset($CONFIG['enable_watermark'])) {
                // modpack installed ? Then we check for an orig image
                if (file_exists($CONFIG['fullpath'] . $row['filepath'] . $CONFIG['orig_pfx'] . $row['filename'])) {
                    $row['filename'] = $CONFIG['orig_pfx'] . $row['filename'];
                }
            }
            $image = $CONFIG['fullpath'] . $row['filepath'] . $row['filename'];
            $dest_dir = $CONFIG['fullpath'] . 'edit/';
            $filename = $row['filename'];
            $CONFIG['read_iptc_data'] = 0;
            require 'include/picmgmt.inc.php';
            if (is_known_filetype($image)) {
                if (is_image($image)) {
                    $imagesize = getimagesize($image);
                    if (max($imagesize[0], $imagesize[1]) < $size) {
                        $pic_data['html'] = "<img src=\"" . $image . "\" class=\"image\" alt=\"" . $image . "\" border=\"0\">";
                    } else {
                        // Do some cleanup in the edit directory.
                        spring_cleaning('./albums/edit', 900);
                        // is a file with the same name already in the edit dir?
                        while (file_exists($dest_dir . $filename)) {
                            $filename = ++$nr . '_' . $row['filename'];
                        }
                        //resize the image into the edit dir
                        if ($CONFIG['enable_watermark'] == 1) {
                            resize_image($image, $dest_dir . $filename, $size, $CONFIG['thumb_method'], 'any', 'true');
                        } else {
                            resize_image($image, $dest_dir . $filename, $size, $CONFIG['thumb_method'], 'any');
                        }
                        $pic_data['html'] = "<img src=\"" . $dest_dir . $filename . "\" class=\"image\" alt=\"" . $dest_dir . "\" border=\"0\">";
                        $image = $dest_dir . $filename;
                        $row['filename'] = $filename;
                    }
                }
            }
        }
    }
    if ($mime_content_image['content'] == 'image') {
        $counter = null;
        // do we have an image > than min resize size
        $html = "<select name=\"resize_id\" class=\"listbox_lang\">";
        foreach ($sizes as $key => $value) {
            if ($value['x'] <= max($pic_data['pwidth'], $pic_data['pheight'])) {
                $html .= "<option value=\"{$value['x']}\">{$value['x']} {$lang_download_resized['px']}</option>";
                $counter++;
            }
        }
        $html .= "</select>";
        if ($counter < 1) {
            return $pic_data;
        }
        //return if we have no dropdown entry
        $album == 'search' ? $referer = "displayimage.php?pos=-{$pic_data['pid']}" : ($referer = null);
        if ($row['filename']) {
            $down_link = "<a href = \"index.php?file=download_resized/download_resized&filename={$row['filename']}&image={$image}\">{$lang_download_resized['download']}</a>";
        } else {
            $file_down_data = '';
        }
        $download_resized_data = <<<EOT
\t\t<table class="tableh" width="100%">
\t\t\t<tr>
\t\t\t\t<td align="center">
\t\t\t\t<form action="{$referer}" method="post">
\t\t\t\t  \t{$added}{$lang_download_resized[resize]}: {$html}
\t\t\t\t\t<input type="hidden" value="{$pic_data['pid']}" name="resize_pid" />
\t    \t\t\t<input type="submit" value="{$lang_download_resized[send_data]}" class="comment_button" />
\t\t\t\t</form>
\t\t\t\t{$down_link}
\t\t\t\t</td>
\t\t\t</tr>
\t\t</table>

EOT;
        $pic_data['html'] = $download_resized_data . $pic_data['html'];
    }
    return $pic_data;
}
Esempio n. 6
0
}
// Retrieve DB stored configuration
$result = cpg_db_query("SELECT name, value FROM {$CONFIG['TABLE_CONFIG']}");
while ($row = $result->fetchAssoc()) {
    $CONFIG[$row['name']] = $row['value'];
}
// while
$result->free();
// Check if Coppermine is allowed to store cookies (cookie consent is required and user has agreed to store cookies)
define('CPG_COOKIES_ALLOWED', $CONFIG['cookies_need_consent'] && !$superCage->cookie->keyExists($CONFIG['cookie_name'] . '_cookies_allowed') ? false : true);
// A space cannot be stored in the config table since the value field is VARCHAR, so %20 is used instead.
if ($CONFIG['keyword_separator'] == '%20') {
    $CONFIG['keyword_separator'] = ' ';
}
if ($CONFIG['log_mode']) {
    spring_cleaning('logs', $CONFIG['log_retention'] > 0 ? $CONFIG['log_retention'] : CPG_DAY * 2);
}
// Record User's IP address
$raw_ip = $superCage->server->testIp('REMOTE_ADDR') ? $superCage->server->getEscaped('REMOTE_ADDR') : '0.0.0.0';
if ($superCage->server->testIp('HTTP_CLIENT_IP')) {
    $hdr_ip = $superCage->server->getEscaped('HTTP_CLIENT_IP');
} else {
    if ($superCage->server->testIp('HTTP_X_FORWARDED_FOR')) {
        $hdr_ip = $superCage->server->getEscaped('X_FORWARDED_FOR');
    } else {
        $hdr_ip = $raw_ip;
    }
}
// Reference 'site_url' to 'ecards_more_pic_target'
$CONFIG['site_url'] =& $CONFIG['ecards_more_pic_target'];
// Set the site_url in js_vars so that it can be used in js
Esempio n. 7
0
        $user_albums_list = db_fetch_rowset($user_albums);
    } else {
        $user_albums_list = array();
    }
} else {
    $user_albums_list = array();
}
if (!count($public_albums_list) && !count($user_albums_list)) {
    cpg_die(ERROR, $lang_upload_php['err_no_alb_uploadables'], __FILE__, __LINE__);
}
// Assign maximum file size for browser crontrols.
$max_file_size = $CONFIG['max_upl_size'] << 10;
// Create the upload forms using the upload congfiguration.
if (!isset($_REQUEST['control'])) {
    // Do some cleanup in the edit directory.
    spring_cleaning('./albums/edit', 3600);
    // Do some cleaning in the temp data table.
    clean_table();
    // Create upload form headers.
    pageheader($lang_upload_php['title']);
    // Open the form table.
    starttable("100%", $lang_upload_php['title'], 2);
    // Select the form action.
    if (USER_UPLOAD_FORM == '0') {
        // The user has the single upload only form. Send the request to db_input.php.
        open_form('db_input.php');
    } else {
        // Direct the request to this script and print the form instructions.
        open_form($_SERVER['PHP_SELF']);
        form_instructions();
    }