Example #1
0
/**
 * Write the User Signature.
 */
function setSig($data_dir, $username, $number, $value)
{
    // Limit signature size to 64KB (database BLOB limit)
    if (strlen($value) > 65536) {
        error_option_save(_("Signature is too big."));
        return;
    }
    $filename = getHashedFile($username, $data_dir, "{$username}.si{$number}");
    /* Open the file for writing, or else display an error to the user. */
    if (!($file = @fopen("{$filename}.tmp", 'w'))) {
        logout_error(sprintf(_("Signature file, %s, could not be opened. Contact your system administrator to resolve this issue."), $filename . '.tmp'));
        exit;
    }
    if (sq_fwrite($file, $value) === FALSE) {
        logout_error(sprintf(_("Signature file, %s, could not be written. Contact your system administrator to resolve this issue."), $filename . '.tmp'));
        exit;
    }
    fclose($file);
    if (!@copy($filename . '.tmp', $filename)) {
        logout_error(sprintf(_("Signature file, %s, could not be copied from temporary file, %s. Contact your system administrator to resolve this issue."), $filename, $filename . '.tmp'));
        exit;
    }
    @unlink($filename . '.tmp');
    @chmod($filename, 0600);
}
Example #2
0
/**
 * Saves the draft folder option.
 * @param object $option SquirrelOption object
 * @since 1.3.2
 */
function save_option_draft_folder($option)
{
    global $data_dir, $username;
    if (strtolower($option->new_value) == 'inbox') {
        // make sure that it is not INBOX
        error_option_save(_("You can't select INBOX as Draft folder."));
    } else {
        /* Set move to draft on or off. */
        $draft_on = $option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON;
        setPref($data_dir, $username, 'save_as_draft', $draft_on);
        /* Now just save the option as normal. */
        save_option($option);
    }
}