コード例 #1
0
 if (strtolower($pi['extension']) == 'zip') {
     // Let's decompress the zip file into the 'plog-content/uploads/' folder and then redirect the user to plog-import.php
     include PLOGGER_DIR . 'plog-includes/lib/pclzip-2-4/pclzip.lib.php';
     // Zip file to extract
     $archive = new PclZip($_FILES['userfile']['tmp_name']);
     // Create a temporary folder in 'plog-content/uploads/' based on the .zip file name
     $zipname = strtolower(sanitize_filename(substr($_FILES['userfile']['name'], 0, -4)));
     $zipdir = $config['basedir'] . 'plog-content/uploads/' . $zipname;
     $zipdirkey = md5($zipdir);
     $zipresult = makeDirs($zipdir);
     if (is_safe_mode()) {
         chmod_ftp($zipdir, 0777);
     }
     // Extract to 'plog-content/uploads/' folder
     $results = $archive->extract(PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_PATH, $zipdir);
     if (is_safe_mode()) {
         chmod_ftp($zipdir);
     }
     if ($results == 0) {
         // Failed
         $output .= "\n\t" . '<p class="errors">' . plog_tr('Error') . ': ' . $archive->errorInfo(true) . '</p>' . "\n";
     } else {
         // Unzip succeeded - doesn't necessarily mean that saving the images succeeded
         $errors = array();
         foreach ($results as $r) {
             if ($r['status'] != 'ok') {
                 $errors[] = $r;
             }
         }
         if (empty($errors)) {
             // Let's redirect to the import interface.
コード例 #2
0
ファイル: plog-import.php プロジェクト: nadams810/ploto
     $real_directory = $directories[$_GET['directory']];
     $show_directory .= substr($real_directory, strlen($upload_directory));
 } else {
     $real_directory = $upload_directory;
 }
 $files = get_files($real_directory);
 if (count($files) > 0) {
     $percent = isset($_GET['nojs']) ? '100%' : '0%';
     if (count($files) > 0) {
         $text = count($files) == 1 ? plog_tr('image') : plog_tr('images');
         $output .= "\n\n\t\t" . '<p class="actions">' . sprintf(plog_tr('You are currently looking at %s within the %s directory.'), '<strong>' . count($files) . '</strong> ' . $text, '<strong>' . $show_directory . '</strong>') . '<br /><br />';
         $output .= "\n\t\t" . sprintf(plog_tr('Creating thumbnails: %s done.'), '<span id="progress" class="strong">' . $percent . '</span>') . '</p>' . "\n";
     }
 }
 // Check to make sure album is writable and readable, and issue warning
 if (!is_safe_mode() && (!is_writable($real_directory) || !is_readable($real_directory))) {
     $output .= "\n\n\t\t" . '<p class="errors">' . plog_tr('Warning: This directory does not have the proper permissions settings! You must make this directory writable (CHMOD) using your FTP software, or import may fail.') . '</p>';
 }
 $albums = get_albums();
 $queue_func = '';
 $keys = array();
 if ($config['allow_comments']) {
     $comment = plog_tr('Allow Comments') . '?';
     $comment_type = 'checkbox" checked="checked';
 } else {
     $comment = '&nbsp;';
     $comment_type = 'hidden';
 }
 sort($files);
 for ($i = 0; $i < count($files); $i++) {
     $file_key = md5($files[$i]);
コード例 #3
0
function configure_plogger($form)
{
    // Use a random timestamp from the past to keep the existing thumbnails
    $long_ago = 1096396500;
    $thumbnail_sizes = array(THUMB_SMALL => 100, THUMB_LARGE => 500, THUMB_RSS => 400, THUMB_NAV => 60);
    foreach ($thumbnail_sizes as $key => $size) {
        $resize = $key == THUMB_SMALL || $key == THUMB_NAV ? 3 : 2;
        $sql = "INSERT INTO `" . PLOGGER_TABLE_PREFIX . "thumbnail_config` (`id`, `update_timestamp`, `max_size`, `resize_option`)\n\t\tVALUES('{$key}', '{$long_ago}', '{$size}', '{$resize}')";
        mysql_query($sql);
    }
    $config['gallery_url'] = 'http://' . $_SERVER['SERVER_NAME'] . dirname(dirname($_SERVER['PHP_SELF']));
    // Remove plog-admin/ from the end, if present .. is there a better way to determine the full url?
    if (strpos($config['gallery_url'], 'plog-admin/')) {
        $config['gallery_url'] = substr($config['gallery_url'], 0, strpos($config['gallery_url'], 'plog-admin/'));
    }
    // Verify that gallery URL contains a trailing slash. if not, add one.
    if ($config['gallery_url'][strlen($config['gallery_url']) - 1] != '/') {
        $config['gallery_url'] .= '/';
    }
    // Verify that the gallery URL begins with 'http://' for mod_rewrite 301 redirects
    if (strpos($config['gallery_url'], 'http://') === false) {
        $config['gallery_url'] = 'http://' . $config['gallery_url'];
    }
    $config['admin_username'] = $form['admin_username'];
    $config['admin_password'] = $form['admin_password'];
    $config['admin_email'] = $form['admin_email'];
    $config['gallery_name'] = $form['gallery_name'];
    $config = array_map('mysql_real_escape_string', $config);
    $row_exist = mysql_query("SELECT * FROM `" . PLOGGER_TABLE_PREFIX . "config`");
    $row_exist_num = mysql_num_rows($row_exist);
    if ($row_exist_num == 0) {
        $query = "INSERT INTO `" . PLOGGER_TABLE_PREFIX . "config`\n\t\t\t(`theme_dir`,\n\t\t\t`compression`,\n\t\t\t`thumb_num`,\n\t\t\t`admin_username`,\n\t\t\t`admin_email`,\n\t\t\t`admin_password`,\n\t\t\t`date_format`,\n\t\t\t`feed_title`,\n\t\t\t`gallery_name`,\n\t\t\t`gallery_url`)\n\t\t\tVALUES\n\t\t\t('default',\n\t\t\t75,\n\t\t\t20,\n\t\t\t'{$config['admin_username']}',\n\t\t\t'{$config['admin_email']}',\n\t\t\tMD5('{$config['admin_password']}'),\n\t\t\t'n.j.Y',\n\t\t\t'Plogger Photo Feed',\n\t\t\t'{$config['gallery_name']}',\n\t\t\t'{$config['gallery_url']}')";
    } else {
        $query = "UPDATE `" . PLOGGER_TABLE_PREFIX . "config` SET\n\t\t\t`theme_dir` = 'default',\n\t\t\t`compression` = 75,\n\t\t\t`thumb_num` = 20,\n\t\t\t`admin_username` = '{$config['admin_username']}',\n\t\t\t`admin_email` = '{$config['admin_email']}',\n\t\t\t`admin_password` = MD5('{$config['admin_password']}'),\n\t\t\t`date_format` = 'n.j.Y',\n\t\t\t`feed_title` = 'Plogger Photo Feed',\n\t\t\t`gallery_name` = '{$config['gallery_name']}',\n\t\t\t`gallery_url` = '{$config['gallery_url']}'";
    }
    mysql_query($query);
    // Create the FTP columns in the config table if safe_mode enabled/
    if (is_safe_mode() && isset($_SESSION['ftp_values'])) {
        configure_ftp($_SESSION['ftp_values']);
    }
    // Send an email with the username and password
    $from = str_replace('www.', '', $_SERVER['HTTP_HOST']);
    ini_set('sendmail_from', 'noreply@' . $from);
    // Set for Windows machines
    @mail($config['admin_email'], plog_tr('[Plogger] Your new gallery'), plog_tr('You have successfully installed your new Plogger gallery.') . "\n\n" . sprintf(plog_tr('You can log in and manage it at %s'), $config['gallery_url'] . 'plog-admin/') . "\n\n" . plog_tr('Username') . ': ' . $config['admin_username'] . "\n" . plog_tr('Password') . ': ' . $config['admin_password'], 'From: Plogger <noreply@' . $from . '>');
}
コード例 #4
0
ファイル: plog-functions.php プロジェクト: nadams810/ploto
function generate_thumb($path, $prefix, $type = THUMB_SMALL)
{
    global $config, $thumbnail_config;
    $thumb_config = $thumbnail_config[$type];
    // For relative paths assume that they are relative to 'plog-content/images/' directory,
    // otherwise just use the given path
    if (file_exists($path)) {
        $source_file_name = $path;
        if ($type == THUMB_THEME) {
            $cache_path = 'themes/';
        } else {
            $cache_path = 'uploads/';
        }
    } else {
        $source_file_name = $config['basedir'] . 'plog-content/images/' . SmartStripSlashes($path);
        $cache_path = dirname(SmartStripSlashes($path)) . '/' . $thumb_config['type'] . '/';
    }
    // The file might have been deleted and since phpThumb dies in that case
    // try to do something sensible so that the rest of the images can still be seen
    // There is a problem in safe mode - if the script and picture file are owned by
    // different users, then the file cannot be read.
    if (!is_readable($source_file_name)) {
        return false;
    }
    $imgdata = @getimagesize($source_file_name);
    if (!$imgdata) {
        // Unknown image format, bail out
        // Do we want to have video support in the Plogger core?
        //return 'plog-graphics/thumb-video.gif';
        return false;
    }
    // Attributes of original image
    $orig_width = $imgdata[0];
    $orig_height = $imgdata[1];
    // XXX: food for thought - maybe we can return URL to some kind of error image
    // if this function fails?
    $base_filename = sanitize_filename(basename($path));
    if ($thumb_config['disabled']) {
        return $config['gallery_url'] . 'plog-content/images/' . $path;
    }
    $prefix = $prefix . '-';
    $thumbpath = $config['basedir'] . 'plog-content/thumbs/' . $cache_path . $prefix . $base_filename;
    $thumburl = $config['gallery_url'] . 'plog-content/thumbs/' . $cache_path . $prefix . $base_filename;
    // If thumbnail file already exists and is generated after data for a thumbnail type
    // has been changed, then we assume that the thumbnail is valid.
    if (file_exists($thumbpath)) {
        $thumbnail_timestamp = @filemtime($thumbpath);
        if ($thumb_config['timestamp'] < $thumbnail_timestamp) {
            return $thumburl;
        }
    }
    // Create the same directory structure as the image under plog-content/thumbs/
    include_once PLOGGER_DIR . 'plog-admin/plog-admin-functions.php';
    if (!makeDirs(dirname($thumbpath))) {
        return sprintf(plog_tr('Error creating path %s'), dirname($thumbpath));
    }
    // If dimensions of source image are smaller than those of the requested
    // thumbnail, then use the original image as thumbnail unless fullsize images are disabled
    if ($orig_width <= $thumb_config['size'] && $orig_height <= $thumb_config['size']) {
        // if fullsize image access is disabled, copy the file to the thumbs folder
        if ($config['allow_fullpic'] == 0) {
            copy($source_file_name, $thumbpath);
            return $thumburl;
            // otherwise return the original file path
        } else {
            return $config['gallery_url'] . 'plog-content/images/' . $path;
        }
    }
    // No existing thumbnail found or thumbnail config has changed,
    // generate new thumbnail file
    require_once PLOGGER_DIR . 'plog-includes/lib/phpthumb/phpthumb.class.php';
    $phpThumb = new phpThumb();
    // Set data
    $phpThumb->setSourceFileName($source_file_name);
    switch ($thumb_config['resize_option']) {
        // Resize to width
        case 0:
            $phpThumb->w = $thumb_config['size'];
            break;
            // Resize to height
        // Resize to height
        case 1:
            $phpThumb->h = $thumb_config['size'];
            break;
            // Use square thumbnails
        // Use square thumbnails
        case 3:
            $phpThumb->zc = 1;
            $phpThumb->h = $thumb_config['size'];
            $phpThumb->w = $thumb_config['size'];
            break;
            // Resize to longest side
        // Resize to longest side
        case 2:
        default:
            if ($imgdata[0] > $imgdata[1]) {
                $phpThumb->w = $thumb_config['size'];
            } else {
                $phpThumb->h = $thumb_config['size'];
            }
    }
    $phpThumb->q = $config['compression'];
    if ($type == THUMB_NAV) {
        $phpThumb->zc = 1;
        $phpThumb->h = $thumb_config['size'];
        $phpThumb->w = $thumb_config['size'];
    }
    if ($type == THUMB_THEME) {
        $phpThumb->w = $thumb_config['size'];
    }
    // Set options (see phpThumb.config.php)
    // here you must preface each option with "config_"
    // Disable ImageMagick - set to false for localhost testing
    // ImageMagick seems to cause some issues on localhost using FF or Chrome
    $phpThumb->config_prefer_imagemagick = false;
    // We want to use the original image for thumbnail creation, not the EXIF stored thumbnail
    $phpThumb->config_use_exif_thumbnail_for_speed = false;
    // Set error handling (optional)
    $phpThumb->config_error_die_on_error = false;
    // If safe_mode enabled, open the permissions first
    if (is_safe_mode()) {
        $thumb_path = dirname($thumbpath) . '/';
        chmod_ftp($thumb_path, 0777);
    }
    // Generate & output thumbnail
    if ($phpThumb->GenerateThumbnail()) {
        $phpThumb->RenderToFile($thumbpath);
    } else {
        // do something with debug/error messages
        die('Failed: ' . implode("\n", $phpThumb->debugmessages));
    }
    @chmod($thumbpath, PLOGGER_CHMOD_FILE);
    // If safe_mode enabled, close the permissions back down to the default
    if (is_safe_mode()) {
        chmod_ftp($thumb_path);
    }
    return $thumburl;
}
コード例 #5
0
function plogger_generate_server_info()
{
    global $config, $PLOGGER_DBH;
    if (isset($_SESSION['plogger_logged_in'])) {
        $server_data = '<div id="server-info" style="display: none;">';
        $arg = explode('/', $_SERVER['SERVER_SOFTWARE']);
        $software_type = isset($arg[0]) ? $arg[0] : '';
        $software_version = isset($arg[1]) ? $arg[1] : '';
        $software_distro = isset($arg[2]) ? $arg[2] : '';
        if (PLOGGER_DB_TYPE == 'mysql') {
            $prettyname = 'MySQL';
        } elseif (PLOGGER_DB_TYPE == 'pgsql') {
            $prettyname = 'PostgreSQL';
        }
        $server_ver = $PLOGGER_DBH->getAttribute(PDO::ATTR_SERVER_VERSION);
        $server_data .= "\n\t\t\t" . '<strong>' . plog_tr('Server Software') . ':</strong> ' . $software_type . '/' . $software_version . ' ' . $software_distro . '<br />
			<strong>' . plog_tr('PHP Version') . ':</strong> ' . phpversion() . ' (' . strtoupper(php_sapi_name()) . ')<br />
			<strong>' . plog_tr($prettyname . ' Version') . ':</strong> ' . $server_ver . '<br />
			<strong>' . plog_tr('GD Version') . ':</strong>';
        /* Thanks to the Pixelpost Crew for the gd_info code below */
        if (function_exists('gd_info')) {
            $gd_info1 = gd_info();
            $gd_info = $gd_info1['GD Version'];
            if ($gd_info == "") {
                $gd_info = plog_tr('Not installed');
            } else {
                if ($gd_info1['JPEG Support']) {
                    $gd_info .= plog_tr(' with JPEG support');
                }
            }
        }
        // Determine the limiting setting for upload sizes
        $max_upload = intval(ini_get('upload_max_filesize'));
        $max_post = intval(ini_get('post_max_size')) * 0.75;
        $file_limit = $max_upload < $max_post ? $max_upload . 'MB' : $max_post . 'MB';
        $server_data .= ' ' . $gd_info . '<br />
			<strong>' . plog_tr('Session Save Path') . ':</strong> ' . session_save_path() . '<br />
			<strong>' . plog_tr('File Upload Size Limit') . ':</strong> ' . $file_limit . '<br />
			<strong>' . plog_tr('Temporary Memory Limit') . ':</strong> ' . ini_get('memory_limit') . '<br />
			<strong>' . plog_tr('Code Run Time Limit') . ':</strong> ' . ini_get('max_execution_time') . 's<br />';
        if (is_safe_mode()) {
            $server_data .= "\n\t\t\t" . '<strong>safe_mode enabled</strong><br />';
        }
        $server_data .= "\n\t\t" . '</div><!-- /server-info -->';
        return $server_data;
    }
    return false;
}
コード例 #6
0
function configure_plogger($form)
{
    global $PLOGGER_DBH;
    // Use a random timestamp from the past to keep the existing thumbnails
    $long_ago = 1096396500;
    $thumbnail_sizes = array(THUMB_SMALL => 100, THUMB_LARGE => 500, THUMB_RSS => 400, THUMB_NAV => 60);
    foreach ($thumbnail_sizes as $key => $size) {
        $resize = $key == THUMB_SMALL || $key == THUMB_NAV ? 3 : 2;
        $sql = "INSERT INTO \"" . PLOGGER_TABLE_PREFIX . "thumbnail_config\" (\"id\", \"update_timestamp\", \"max_size\", \"resize_option\")\n\t\tVALUES('{$key}', '{$long_ago}', '{$size}', '{$resize}')";
        run_query($sql);
    }
    if ($_SERVER['HTTPS'] == "on") {
        $srvproto = 'https://';
    } else {
        $srvproto = 'http://';
    }
    $config['gallery_url'] = $srvproto . $_SERVER['HTTP_HOST'] . dirname(dirname($_SERVER['PHP_SELF']));
    // Remove plog-admin/ from the end, if present .. is there a better way to determine the full url?
    if (strpos($config['gallery_url'], 'plog-admin/')) {
        $config['gallery_url'] = substr($config['gallery_url'], 0, strpos($config['gallery_url'], 'plog-admin/'));
    }
    // Verify that gallery URL contains a trailing slash. if not, add one.
    if ($config['gallery_url'][strlen($config['gallery_url']) - 1] != '/') {
        $config['gallery_url'] .= '/';
    }
    $config['admin_username'] = $form['admin_username'];
    $config['admin_password'] = $form['admin_password'];
    $config['admin_email'] = $form['admin_email'];
    $config['gallery_name'] = $form['gallery_name'];
    $config = array_map(array($PLOGGER_DBH, 'quote'), $config);
    $row_exist = run_query("SELECT * FROM \"" . PLOGGER_TABLE_PREFIX . "config\"");
    $row_exist_num = $row_exist->rowCount();
    if ($row_exist_num == 0) {
        $query = "INSERT INTO \"" . PLOGGER_TABLE_PREFIX . "config\"\n\t\t\t(\"theme_dir\",\n\t\t\t\"compression\",\n\t\t\t\"thumb_num\",\n\t\t\t\"admin_username\",\n\t\t\t\"admin_email\",\n\t\t\t\"admin_password\",\n\t\t\t\"date_format\",\n\t\t\t\"feed_title\",\n\t\t\t\"gallery_name\",\n\t\t\t\"gallery_url\")\n\t\t\tVALUES\n\t\t\t('default',\n\t\t\t75,\n\t\t\t20,\n\t\t\t{$config['admin_username']},\n\t\t\t{$config['admin_email']},\n\t\t\tMD5({$config['admin_password']}),\n\t\t\t'n.j.Y',\n\t\t\t'Plogger Photo Feed',\n\t\t\t{$config['gallery_name']},\n\t\t\t{$config['gallery_url']})";
    } else {
        $query = "UPDATE \"" . PLOGGER_TABLE_PREFIX . "config\" SET\n\t\t\t\"theme_dir\" = 'default',\n\t\t\t\"compression\" = 75,\n\t\t\t\"thumb_num\" = 20,\n\t\t\t\"admin_username\" = {$config['admin_username']},\n\t\t\t\"admin_email\" = {$config['admin_email']},\n\t\t\t\"admin_password\" = MD5({$config['admin_password']}),\n\t\t\t\"date_format\" = 'n.j.Y',\n\t\t\t\"feed_title\" = 'Plogger Photo Feed',\n\t\t\t\"gallery_name\" = {$config['gallery_name']},\n\t\t\t\"gallery_url\" = {$config['gallery_url']}";
    }
    run_query($query);
    // Create the FTP columns in the config table if safe_mode enabled/
    if (is_safe_mode() && isset($_SESSION['ftp_values'])) {
        configure_ftp($_SESSION['ftp_values']);
    }
    // Send an email with the username and password
    $from = str_replace('www.', '', $_SERVER['HTTP_HOST']);
    ini_set('sendmail_from', 'noreply@' . $from);
    // Set for Windows machines
    @mail($config['admin_email'], plog_tr('[Plogger] Your new gallery'), plog_tr('You have successfully installed your new Plogger gallery.') . "\n\n" . sprintf(plog_tr('You can log in and manage it at %s'), $config['gallery_url'] . 'plog-admin/') . "\n\n" . plog_tr('Username') . ': ' . $config['admin_username'] . "\n" . plog_tr('Password') . ': ' . $config['admin_password'], 'From: Plogger <noreply@' . $from . '>');
}