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 . '>');
}
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 . '>');
}
Example #3
0
         $ftp_errors = array();
         $form = array_map('stripslashes', $_POST);
         $form = array_map('trim', $_POST);
         // Check the form input values
         $ftp_form_check = check_ftp_form($form);
         $form = $ftp_form_check['form'];
         if (!empty($ftp_form_check['form']['errors'])) {
             $ftp_errors = $ftp_form_check['form']['errors'];
         }
         // If no ftp errors so far, check the ftp information
         if (empty($ftp_errors)) {
             $ftp_check = check_ftp($form['ftp_host'], $form['ftp_user'], $form['ftp_pass'], $form['ftp_path']);
         }
         // If still no ftp errors, add the information to the database
         if (empty($ftp_check)) {
             configure_ftp($form);
             $config['ftp_host'] = $form['ftp_host'];
             $config['ftp_user'] = $form['ftp_user'];
             $config['ftp_pass'] = $form['ftp_pass'];
             $config['ftp_path'] = $form['ftp_path'];
         } else {
             // Otherwise, set up the errors for display later
             $ftp_errors = $ftp_check;
         }
     }
     if (!isset($config['ftp_host'])) {
         // Do we need an upgrade for people who used SVN only code that stored
         // FTP workaround data in plog-config.php?
         $needs_ftp = true;
     }
 }